skrypt-ai 0.4.2 → 0.6.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 +101 -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.d.ts +0 -4
- package/dist/autofix/index.js +10 -24
- package/dist/capture/browser.d.ts +11 -0
- package/dist/capture/browser.js +173 -0
- package/dist/capture/diff.d.ts +23 -0
- package/dist/capture/diff.js +52 -0
- package/dist/capture/index.d.ts +23 -0
- package/dist/capture/index.js +210 -0
- package/dist/capture/naming.d.ts +17 -0
- package/dist/capture/naming.js +45 -0
- package/dist/capture/parser.d.ts +15 -0
- package/dist/capture/parser.js +80 -0
- package/dist/capture/types.d.ts +57 -0
- package/dist/capture/types.js +1 -0
- package/dist/cli.js +20 -3
- package/dist/commands/autofix.js +136 -120
- package/dist/commands/cron.js +58 -47
- package/dist/commands/deploy.js +123 -102
- package/dist/commands/generate.js +125 -7
- package/dist/commands/heal.d.ts +10 -0
- package/dist/commands/heal.js +201 -0
- package/dist/commands/i18n.js +146 -111
- 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/lint.js +50 -44
- package/dist/commands/llms-txt.js +59 -49
- package/dist/commands/login.js +63 -34
- package/dist/commands/mcp.js +6 -0
- package/dist/commands/monitor.js +13 -8
- package/dist/commands/qa.d.ts +2 -0
- package/dist/commands/qa.js +43 -0
- package/dist/commands/review-pr.js +108 -92
- package/dist/commands/sdk.js +128 -122
- package/dist/commands/security.d.ts +2 -0
- package/dist/commands/security.js +109 -0
- package/dist/commands/test.js +91 -92
- package/dist/commands/version.js +104 -75
- package/dist/commands/watch.js +130 -114
- package/dist/config/types.js +2 -2
- package/dist/context-hub/index.d.ts +23 -0
- package/dist/context-hub/index.js +179 -0
- package/dist/context-hub/mappings.d.ts +8 -0
- package/dist/context-hub/mappings.js +55 -0
- package/dist/context-hub/types.d.ts +33 -0
- package/dist/context-hub/types.js +1 -0
- package/dist/generator/generator.js +39 -6
- package/dist/generator/types.d.ts +7 -0
- package/dist/generator/writer.d.ts +3 -1
- package/dist/generator/writer.js +36 -7
- 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/llm/anthropic-client.d.ts +1 -0
- package/dist/llm/anthropic-client.js +3 -1
- package/dist/llm/index.d.ts +6 -4
- package/dist/llm/index.js +76 -261
- package/dist/llm/openai-client.d.ts +1 -0
- package/dist/llm/openai-client.js +7 -2
- package/dist/plugins/index.js +7 -0
- package/dist/qa/checks.d.ts +10 -0
- package/dist/qa/checks.js +492 -0
- package/dist/qa/fixes.d.ts +30 -0
- package/dist/qa/fixes.js +277 -0
- package/dist/qa/index.d.ts +29 -0
- package/dist/qa/index.js +187 -0
- package/dist/qa/types.d.ts +24 -0
- package/dist/qa/types.js +1 -0
- package/dist/scanner/csharp.d.ts +23 -0
- package/dist/scanner/csharp.js +421 -0
- package/dist/scanner/index.js +53 -26
- package/dist/scanner/java.d.ts +39 -0
- package/dist/scanner/java.js +318 -0
- package/dist/scanner/kotlin.d.ts +23 -0
- package/dist/scanner/kotlin.js +389 -0
- package/dist/scanner/php.d.ts +57 -0
- package/dist/scanner/php.js +351 -0
- package/dist/scanner/python.js +17 -0
- package/dist/scanner/ruby.d.ts +36 -0
- package/dist/scanner/ruby.js +431 -0
- package/dist/scanner/swift.d.ts +25 -0
- package/dist/scanner/swift.js +392 -0
- package/dist/scanner/types.d.ts +1 -1
- package/dist/template/content/docs/_navigation.json +46 -0
- package/dist/template/content/docs/_sidebars.json +684 -0
- package/dist/template/content/docs/core.md +4544 -0
- package/dist/template/content/docs/index.mdx +89 -0
- package/dist/template/content/docs/integrations.md +1158 -0
- package/dist/template/content/docs/llms-full.md +403 -0
- package/dist/template/content/docs/llms.txt +4588 -0
- package/dist/template/content/docs/other.md +10379 -0
- package/dist/template/content/docs/tools.md +746 -0
- package/dist/template/content/docs/types.md +531 -0
- package/dist/template/docs.json +13 -11
- package/dist/template/mdx-components.tsx +27 -2
- package/dist/template/package.json +6 -0
- package/dist/template/public/search-index.json +1 -1
- package/dist/template/scripts/build-search-index.mjs +149 -13
- package/dist/template/src/app/api/chat/route.ts +83 -128
- package/dist/template/src/app/docs/[...slug]/page.tsx +75 -20
- package/dist/template/src/app/docs/llms-full.md +151 -4
- package/dist/template/src/app/docs/llms.txt +2464 -847
- package/dist/template/src/app/docs/page.mdx +48 -38
- package/dist/template/src/app/layout.tsx +3 -1
- package/dist/template/src/app/page.tsx +22 -8
- package/dist/template/src/components/ai-chat.tsx +73 -64
- package/dist/template/src/components/breadcrumbs.tsx +21 -23
- package/dist/template/src/components/copy-button.tsx +13 -9
- package/dist/template/src/components/copy-page-button.tsx +54 -0
- package/dist/template/src/components/docs-layout.tsx +37 -25
- package/dist/template/src/components/header.tsx +51 -10
- package/dist/template/src/components/mdx/card.tsx +17 -3
- package/dist/template/src/components/mdx/code-block.tsx +13 -9
- package/dist/template/src/components/mdx/code-group.tsx +13 -8
- package/dist/template/src/components/mdx/heading.tsx +15 -2
- package/dist/template/src/components/mdx/highlighted-code.tsx +13 -8
- package/dist/template/src/components/mdx/index.tsx +2 -0
- package/dist/template/src/components/mdx/mermaid.tsx +110 -0
- package/dist/template/src/components/mdx/screenshot.tsx +150 -0
- package/dist/template/src/components/scroll-to-hash.tsx +48 -0
- package/dist/template/src/components/sidebar.tsx +12 -18
- package/dist/template/src/components/table-of-contents.tsx +9 -0
- package/dist/template/src/lib/highlight.ts +3 -88
- package/dist/template/src/lib/navigation.ts +159 -0
- 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 +17 -6
- package/dist/utils/files.d.ts +9 -1
- package/dist/utils/files.js +59 -10
- package/dist/utils/validation.d.ts +0 -3
- package/dist/utils/validation.js +0 -26
- package/package.json +5 -1
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
/**
|
|
3
|
+
* Scanner for Swift source files
|
|
4
|
+
* Extracts: public/open classes, structs, enums, protocols, actors, functions, methods
|
|
5
|
+
*/
|
|
6
|
+
export class SwiftScanner {
|
|
7
|
+
languages = ['swift'];
|
|
8
|
+
canHandle(filePath) {
|
|
9
|
+
return (/\.swift$/.test(filePath) &&
|
|
10
|
+
!filePath.endsWith('Tests.swift') &&
|
|
11
|
+
!filePath.endsWith('Test.swift') &&
|
|
12
|
+
!filePath.includes('/Tests/'));
|
|
13
|
+
}
|
|
14
|
+
async scanFile(filePath) {
|
|
15
|
+
try {
|
|
16
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
17
|
+
const elements = [];
|
|
18
|
+
const errors = [];
|
|
19
|
+
const lines = source.split('\n');
|
|
20
|
+
// Infer module name from path
|
|
21
|
+
const packageName = this.inferModuleName(filePath);
|
|
22
|
+
// Extract import statements
|
|
23
|
+
const imports = this.extractImports(source);
|
|
24
|
+
// Find all public/open items
|
|
25
|
+
this.extractTypes(source, lines, filePath, packageName, imports, elements);
|
|
26
|
+
this.extractTopLevelFunctions(source, lines, filePath, packageName, imports, elements);
|
|
27
|
+
this.extractMethods(source, lines, filePath, packageName, imports, elements);
|
|
28
|
+
return {
|
|
29
|
+
filePath,
|
|
30
|
+
language: 'swift',
|
|
31
|
+
elements,
|
|
32
|
+
errors
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return {
|
|
37
|
+
filePath,
|
|
38
|
+
language: 'swift',
|
|
39
|
+
elements: [],
|
|
40
|
+
errors: [`Failed to parse: ${err}`]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
inferModuleName(filePath) {
|
|
45
|
+
const parts = filePath.split('/');
|
|
46
|
+
// Look for Sources/ directory (Swift Package Manager convention)
|
|
47
|
+
const sourcesIndex = parts.indexOf('Sources');
|
|
48
|
+
if (sourcesIndex >= 0 && sourcesIndex + 1 < parts.length) {
|
|
49
|
+
return parts[sourcesIndex + 1] ?? 'unknown';
|
|
50
|
+
}
|
|
51
|
+
// Fall back to parent directory
|
|
52
|
+
return parts[parts.length - 2] ?? 'unknown';
|
|
53
|
+
}
|
|
54
|
+
extractImports(source) {
|
|
55
|
+
const imports = [];
|
|
56
|
+
const regex = /^import\s+(\w+)/gm;
|
|
57
|
+
let match;
|
|
58
|
+
while ((match = regex.exec(source)) !== null) {
|
|
59
|
+
if (match[1])
|
|
60
|
+
imports.push(match[1]);
|
|
61
|
+
}
|
|
62
|
+
return imports;
|
|
63
|
+
}
|
|
64
|
+
extractTypes(source, lines, filePath, packageName, imports, elements) {
|
|
65
|
+
// Match: public/open class/struct/enum/protocol/actor TypeName
|
|
66
|
+
// Allow optional modifiers like "final" or "indirect" between access level and type keyword
|
|
67
|
+
const typeRegex = /^(public|open)\s+(?:(?:final|indirect)\s+)?(class|struct|enum|protocol|actor)\s+(\w+)/gm;
|
|
68
|
+
let match;
|
|
69
|
+
while ((match = typeRegex.exec(source)) !== null) {
|
|
70
|
+
const access = match[1];
|
|
71
|
+
const kind = match[2];
|
|
72
|
+
const name = match[3];
|
|
73
|
+
if (!access || !kind || !name)
|
|
74
|
+
continue;
|
|
75
|
+
const lineNumber = this.getLineNumber(source, match.index);
|
|
76
|
+
const docstring = this.getDocComment(lines, lineNumber - 1);
|
|
77
|
+
const signature = `${access} ${kind} ${name}`;
|
|
78
|
+
elements.push({
|
|
79
|
+
kind: 'class',
|
|
80
|
+
name,
|
|
81
|
+
signature,
|
|
82
|
+
parameters: [],
|
|
83
|
+
docstring,
|
|
84
|
+
filePath,
|
|
85
|
+
lineNumber,
|
|
86
|
+
isExported: true,
|
|
87
|
+
isPublic: true,
|
|
88
|
+
imports,
|
|
89
|
+
packageName,
|
|
90
|
+
sourceContext: this.getSourceContext(lines, lineNumber, 15)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
extractParenContent(source, openIndex) {
|
|
95
|
+
if (source[openIndex] !== '(')
|
|
96
|
+
return null;
|
|
97
|
+
let depth = 0;
|
|
98
|
+
for (let i = openIndex; i < source.length; i++) {
|
|
99
|
+
if (source[i] === '(')
|
|
100
|
+
depth++;
|
|
101
|
+
else if (source[i] === ')') {
|
|
102
|
+
depth--;
|
|
103
|
+
if (depth === 0)
|
|
104
|
+
return source.slice(openIndex + 1, i);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
extractTrailingSignature(source, openIndex) {
|
|
110
|
+
// Find closing paren
|
|
111
|
+
let depth = 0;
|
|
112
|
+
let closeIndex = openIndex;
|
|
113
|
+
for (let i = openIndex; i < source.length; i++) {
|
|
114
|
+
if (source[i] === '(')
|
|
115
|
+
depth++;
|
|
116
|
+
else if (source[i] === ')') {
|
|
117
|
+
depth--;
|
|
118
|
+
if (depth === 0) {
|
|
119
|
+
closeIndex = i;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Scan after ')' for async/throws/rethrows/-> up to '{' or newline
|
|
125
|
+
const afterParen = source.slice(closeIndex + 1);
|
|
126
|
+
const trailingMatch = afterParen.match(/^([^{\n]*)/);
|
|
127
|
+
const trailing = trailingMatch?.[1] ?? '';
|
|
128
|
+
const isAsync = /\basync\b/.test(trailing);
|
|
129
|
+
const isThrows = /\bthrows\b/.test(trailing);
|
|
130
|
+
const isRethrows = /\brethrows\b/.test(trailing);
|
|
131
|
+
const returnMatch = trailing.match(/->\s*(.+?)$/);
|
|
132
|
+
const returnType = returnMatch?.[1]?.trim() || undefined;
|
|
133
|
+
return { closeIndex, isAsync, isThrows, isRethrows, returnType };
|
|
134
|
+
}
|
|
135
|
+
extractTopLevelFunctions(source, lines, filePath, packageName, imports, elements) {
|
|
136
|
+
// Match up to the opening '(' only (allow optional generic params <...>)
|
|
137
|
+
// Allow optional modifiers like static, class, final, override between access level and func
|
|
138
|
+
const funcRegex = /^(public|open)\s+(?:(?:static|class|final|override)\s+)*func\s+(\w+)\s*(?:<[^>]*>\s*)?\(/gm;
|
|
139
|
+
let match;
|
|
140
|
+
while ((match = funcRegex.exec(source)) !== null) {
|
|
141
|
+
const access = match[1];
|
|
142
|
+
const name = match[2];
|
|
143
|
+
if (!access || !name)
|
|
144
|
+
continue;
|
|
145
|
+
// Check if this is at the top level (not indented)
|
|
146
|
+
const lineNumber = this.getLineNumber(source, match.index);
|
|
147
|
+
const lineContent = lines[lineNumber - 1];
|
|
148
|
+
if (!lineContent || /^\s+/.test(lineContent))
|
|
149
|
+
continue;
|
|
150
|
+
const openParenIndex = match.index + match[0].length - 1;
|
|
151
|
+
const paramsStr = this.extractParenContent(source, openParenIndex);
|
|
152
|
+
if (paramsStr === null)
|
|
153
|
+
continue;
|
|
154
|
+
const { isAsync, isThrows, isRethrows, returnType } = this.extractTrailingSignature(source, openParenIndex);
|
|
155
|
+
const docstring = this.getDocComment(lines, lineNumber - 1);
|
|
156
|
+
const parameters = this.parseSwiftParams(paramsStr);
|
|
157
|
+
const signature = this.buildSignature(access, name, paramsStr, isAsync, isThrows, isRethrows, returnType);
|
|
158
|
+
elements.push({
|
|
159
|
+
kind: 'function',
|
|
160
|
+
name,
|
|
161
|
+
signature,
|
|
162
|
+
parameters,
|
|
163
|
+
returnType,
|
|
164
|
+
docstring,
|
|
165
|
+
filePath,
|
|
166
|
+
lineNumber,
|
|
167
|
+
isAsync,
|
|
168
|
+
isExported: true,
|
|
169
|
+
isPublic: true,
|
|
170
|
+
imports,
|
|
171
|
+
packageName,
|
|
172
|
+
sourceContext: this.getSourceContext(lines, lineNumber)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
extractMethods(source, lines, filePath, packageName, imports, elements) {
|
|
177
|
+
// Find type blocks (class/struct/enum/protocol/actor) and extract methods inside them
|
|
178
|
+
const typeBlockRegex = /^(?:public|open)\s+(?:(?:final|indirect)\s+)?(?:class|struct|enum|protocol|actor)\s+(\w+)[^{]*\{/gm;
|
|
179
|
+
let typeMatch;
|
|
180
|
+
while ((typeMatch = typeBlockRegex.exec(source)) !== null) {
|
|
181
|
+
const typeName = typeMatch[1];
|
|
182
|
+
if (!typeName)
|
|
183
|
+
continue;
|
|
184
|
+
const blockStart = typeMatch.index + typeMatch[0].length - 1;
|
|
185
|
+
const blockBody = this.extractBlock(source, blockStart);
|
|
186
|
+
if (!blockBody)
|
|
187
|
+
continue;
|
|
188
|
+
// Find public/open func inside the block — match up to opening '(' only (allow optional generic params)
|
|
189
|
+
// Allow optional modifiers like static, class, final, override between access level and func
|
|
190
|
+
const methodRegex = /^\s+(public|open)\s+(?:(?:static|class|final|override)\s+)*func\s+(\w+)\s*(?:<[^>]*>\s*)?\(/gm;
|
|
191
|
+
let methodMatch;
|
|
192
|
+
while ((methodMatch = methodRegex.exec(blockBody)) !== null) {
|
|
193
|
+
const access = methodMatch[1];
|
|
194
|
+
const name = methodMatch[2];
|
|
195
|
+
if (!access || !name)
|
|
196
|
+
continue;
|
|
197
|
+
const openParenIndex = methodMatch.index + methodMatch[0].length - 1;
|
|
198
|
+
const paramsStr = this.extractParenContent(blockBody, openParenIndex);
|
|
199
|
+
if (paramsStr === null)
|
|
200
|
+
continue;
|
|
201
|
+
const { isAsync, isThrows, isRethrows, returnType } = this.extractTrailingSignature(blockBody, openParenIndex);
|
|
202
|
+
// Calculate line number relative to the full source
|
|
203
|
+
const bodyOffset = blockStart + 1;
|
|
204
|
+
const fullIndex = bodyOffset + methodMatch.index;
|
|
205
|
+
const lineNumber = this.getLineNumber(source, fullIndex);
|
|
206
|
+
const docstring = this.getDocComment(lines, lineNumber - 1);
|
|
207
|
+
const parameters = this.parseSwiftParams(paramsStr);
|
|
208
|
+
const signature = this.buildSignature(access, name, paramsStr, isAsync, isThrows, isRethrows, returnType);
|
|
209
|
+
elements.push({
|
|
210
|
+
kind: 'method',
|
|
211
|
+
name,
|
|
212
|
+
signature,
|
|
213
|
+
parameters,
|
|
214
|
+
returnType,
|
|
215
|
+
docstring,
|
|
216
|
+
filePath,
|
|
217
|
+
lineNumber,
|
|
218
|
+
parentClass: typeName,
|
|
219
|
+
isAsync,
|
|
220
|
+
isExported: true,
|
|
221
|
+
isPublic: true,
|
|
222
|
+
imports,
|
|
223
|
+
packageName,
|
|
224
|
+
sourceContext: this.getSourceContext(lines, lineNumber)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
buildSignature(access, name, paramsStr, isAsync, isThrows, isRethrows, returnType) {
|
|
230
|
+
let sig = `${access} func ${name}(${paramsStr})`;
|
|
231
|
+
if (isAsync)
|
|
232
|
+
sig += ' async';
|
|
233
|
+
if (isThrows)
|
|
234
|
+
sig += ' throws';
|
|
235
|
+
if (isRethrows)
|
|
236
|
+
sig += ' rethrows';
|
|
237
|
+
if (returnType)
|
|
238
|
+
sig += ` -> ${returnType}`;
|
|
239
|
+
return sig;
|
|
240
|
+
}
|
|
241
|
+
extractBlock(source, startIndex) {
|
|
242
|
+
let depth = 0;
|
|
243
|
+
let i = startIndex;
|
|
244
|
+
let start = -1;
|
|
245
|
+
while (i < source.length) {
|
|
246
|
+
if (source[i] === '{') {
|
|
247
|
+
if (depth === 0)
|
|
248
|
+
start = i;
|
|
249
|
+
depth++;
|
|
250
|
+
}
|
|
251
|
+
else if (source[i] === '}') {
|
|
252
|
+
depth--;
|
|
253
|
+
if (depth === 0) {
|
|
254
|
+
return source.slice(start + 1, i);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
i++;
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
parseSwiftParams(paramsStr) {
|
|
262
|
+
if (!paramsStr.trim())
|
|
263
|
+
return [];
|
|
264
|
+
const params = [];
|
|
265
|
+
const parts = this.splitParams(paramsStr);
|
|
266
|
+
for (const part of parts) {
|
|
267
|
+
const trimmed = part.trim();
|
|
268
|
+
if (!trimmed)
|
|
269
|
+
continue;
|
|
270
|
+
// Swift parameter formats:
|
|
271
|
+
// "externalName internalName: Type"
|
|
272
|
+
// "_ internalName: Type"
|
|
273
|
+
// "name: Type"
|
|
274
|
+
// "name: Type = defaultValue"
|
|
275
|
+
const colonIdx = trimmed.indexOf(':');
|
|
276
|
+
if (colonIdx < 0)
|
|
277
|
+
continue;
|
|
278
|
+
const labelPart = trimmed.slice(0, colonIdx).trim();
|
|
279
|
+
let typePart = trimmed.slice(colonIdx + 1).trim();
|
|
280
|
+
// Check for default value
|
|
281
|
+
let defaultValue;
|
|
282
|
+
const equalsIdx = this.findDefaultValueSplit(typePart);
|
|
283
|
+
if (equalsIdx >= 0) {
|
|
284
|
+
defaultValue = typePart.slice(equalsIdx + 1).trim();
|
|
285
|
+
typePart = typePart.slice(0, equalsIdx).trim();
|
|
286
|
+
}
|
|
287
|
+
// Parse label part: could be "externalName internalName", "_ name", or just "name"
|
|
288
|
+
const labelParts = labelPart.split(/\s+/);
|
|
289
|
+
let name;
|
|
290
|
+
if (labelParts.length >= 2) {
|
|
291
|
+
// "external internal" or "_ internal"
|
|
292
|
+
name = labelParts[1] ?? labelParts[0] ?? trimmed;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
name = labelParts[0] ?? trimmed;
|
|
296
|
+
}
|
|
297
|
+
params.push({
|
|
298
|
+
name,
|
|
299
|
+
type: typePart || undefined,
|
|
300
|
+
default: defaultValue
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return params;
|
|
304
|
+
}
|
|
305
|
+
findDefaultValueSplit(typePart) {
|
|
306
|
+
// Find '=' that's not inside generics < >
|
|
307
|
+
let depth = 0;
|
|
308
|
+
for (let i = 0; i < typePart.length; i++) {
|
|
309
|
+
const ch = typePart[i];
|
|
310
|
+
if (ch === '<' || ch === '(' || ch === '[')
|
|
311
|
+
depth++;
|
|
312
|
+
else if (ch === '>' || ch === ')' || ch === ']')
|
|
313
|
+
depth--;
|
|
314
|
+
else if (ch === '=' && depth === 0)
|
|
315
|
+
return i;
|
|
316
|
+
}
|
|
317
|
+
return -1;
|
|
318
|
+
}
|
|
319
|
+
splitParams(str) {
|
|
320
|
+
const parts = [];
|
|
321
|
+
let depth = 0;
|
|
322
|
+
let current = '';
|
|
323
|
+
for (const char of str) {
|
|
324
|
+
if (char === '<' || char === '(' || char === '[' || char === '{')
|
|
325
|
+
depth++;
|
|
326
|
+
else if (char === '>' || char === ')' || char === ']' || char === '}')
|
|
327
|
+
depth--;
|
|
328
|
+
else if (char === ',' && depth === 0) {
|
|
329
|
+
parts.push(current);
|
|
330
|
+
current = '';
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
current += char;
|
|
334
|
+
}
|
|
335
|
+
if (current.trim())
|
|
336
|
+
parts.push(current);
|
|
337
|
+
return parts;
|
|
338
|
+
}
|
|
339
|
+
getLineNumber(source, index) {
|
|
340
|
+
return source.slice(0, index).split('\n').length;
|
|
341
|
+
}
|
|
342
|
+
getDocComment(lines, lineIndex) {
|
|
343
|
+
const comments = [];
|
|
344
|
+
let i = lineIndex - 1;
|
|
345
|
+
while (i >= 0) {
|
|
346
|
+
const lineContent = lines[i];
|
|
347
|
+
if (!lineContent)
|
|
348
|
+
break;
|
|
349
|
+
const line = lineContent.trim();
|
|
350
|
+
// Swift single-line doc comment: ///
|
|
351
|
+
if (line.startsWith('///')) {
|
|
352
|
+
comments.unshift(line.replace(/^\/\/\/\s?/, ''));
|
|
353
|
+
i--;
|
|
354
|
+
}
|
|
355
|
+
else if (line === '') {
|
|
356
|
+
i--;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Check for /** */ block comment (skip blank lines before declaration)
|
|
363
|
+
if (comments.length === 0 && lineIndex > 0) {
|
|
364
|
+
let checkIdx = lineIndex - 1;
|
|
365
|
+
while (checkIdx >= 0 && lines[checkIdx]?.trim() === '')
|
|
366
|
+
checkIdx--;
|
|
367
|
+
if (checkIdx >= 0 && lines[checkIdx]?.includes('*/')) {
|
|
368
|
+
let start = checkIdx;
|
|
369
|
+
while (start >= 0 && !lines[start]?.includes('/**')) {
|
|
370
|
+
start--;
|
|
371
|
+
}
|
|
372
|
+
if (start >= 0 && lines[start]) {
|
|
373
|
+
const block = lines.slice(start, checkIdx + 1).join('\n');
|
|
374
|
+
const cleaned = block
|
|
375
|
+
.replace(/\/\*\*\s?/, '')
|
|
376
|
+
.replace(/\*\//, '')
|
|
377
|
+
.split('\n')
|
|
378
|
+
.map(l => l.trim().replace(/^\*\s?/, ''))
|
|
379
|
+
.filter(Boolean)
|
|
380
|
+
.join('\n');
|
|
381
|
+
return cleaned || undefined;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return comments.length > 0 ? comments.join('\n') : undefined;
|
|
386
|
+
}
|
|
387
|
+
getSourceContext(lines, lineNumber, context = 5) {
|
|
388
|
+
const start = Math.max(0, lineNumber - context - 1);
|
|
389
|
+
const end = Math.min(lines.length, lineNumber + context);
|
|
390
|
+
return lines.slice(start, end).join('\n');
|
|
391
|
+
}
|
|
392
|
+
}
|
package/dist/scanner/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface APIElement {
|
|
|
33
33
|
*/
|
|
34
34
|
export interface ScanResult {
|
|
35
35
|
filePath: string;
|
|
36
|
-
language: 'python' | 'javascript' | 'typescript' | 'go' | 'rust';
|
|
36
|
+
language: 'python' | 'javascript' | 'typescript' | 'go' | 'rust' | 'java' | 'csharp' | 'php' | 'kotlin' | 'swift' | 'ruby';
|
|
37
37
|
elements: APIElement[];
|
|
38
38
|
errors: string[];
|
|
39
39
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"navigation": [
|
|
3
|
+
{
|
|
4
|
+
"group": "API Reference",
|
|
5
|
+
"pages": [
|
|
6
|
+
"api-reference/core",
|
|
7
|
+
"api-reference/tools",
|
|
8
|
+
"api-reference/types",
|
|
9
|
+
"api-reference/integrations",
|
|
10
|
+
"api-reference/other"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"groups": [
|
|
15
|
+
{
|
|
16
|
+
"group": "Core API",
|
|
17
|
+
"pages": [
|
|
18
|
+
"api-reference/core"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"group": "Tools & Utilities",
|
|
23
|
+
"pages": [
|
|
24
|
+
"api-reference/tools"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"group": "Types & Interfaces",
|
|
29
|
+
"pages": [
|
|
30
|
+
"api-reference/types"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"group": "Integrations",
|
|
35
|
+
"pages": [
|
|
36
|
+
"api-reference/integrations"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"group": "Other",
|
|
41
|
+
"pages": [
|
|
42
|
+
"api-reference/other"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|