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.
Files changed (159) hide show
  1. package/dist/auth/index.d.ts +13 -3
  2. package/dist/auth/index.js +101 -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.d.ts +0 -4
  8. package/dist/autofix/index.js +10 -24
  9. package/dist/capture/browser.d.ts +11 -0
  10. package/dist/capture/browser.js +173 -0
  11. package/dist/capture/diff.d.ts +23 -0
  12. package/dist/capture/diff.js +52 -0
  13. package/dist/capture/index.d.ts +23 -0
  14. package/dist/capture/index.js +210 -0
  15. package/dist/capture/naming.d.ts +17 -0
  16. package/dist/capture/naming.js +45 -0
  17. package/dist/capture/parser.d.ts +15 -0
  18. package/dist/capture/parser.js +80 -0
  19. package/dist/capture/types.d.ts +57 -0
  20. package/dist/capture/types.js +1 -0
  21. package/dist/cli.js +20 -3
  22. package/dist/commands/autofix.js +136 -120
  23. package/dist/commands/cron.js +58 -47
  24. package/dist/commands/deploy.js +123 -102
  25. package/dist/commands/generate.js +125 -7
  26. package/dist/commands/heal.d.ts +10 -0
  27. package/dist/commands/heal.js +201 -0
  28. package/dist/commands/i18n.js +146 -111
  29. package/dist/commands/import.d.ts +2 -0
  30. package/dist/commands/import.js +157 -0
  31. package/dist/commands/init.js +19 -7
  32. package/dist/commands/lint.js +50 -44
  33. package/dist/commands/llms-txt.js +59 -49
  34. package/dist/commands/login.js +63 -34
  35. package/dist/commands/mcp.js +6 -0
  36. package/dist/commands/monitor.js +13 -8
  37. package/dist/commands/qa.d.ts +2 -0
  38. package/dist/commands/qa.js +43 -0
  39. package/dist/commands/review-pr.js +108 -92
  40. package/dist/commands/sdk.js +128 -122
  41. package/dist/commands/security.d.ts +2 -0
  42. package/dist/commands/security.js +109 -0
  43. package/dist/commands/test.js +91 -92
  44. package/dist/commands/version.js +104 -75
  45. package/dist/commands/watch.js +130 -114
  46. package/dist/config/types.js +2 -2
  47. package/dist/context-hub/index.d.ts +23 -0
  48. package/dist/context-hub/index.js +179 -0
  49. package/dist/context-hub/mappings.d.ts +8 -0
  50. package/dist/context-hub/mappings.js +55 -0
  51. package/dist/context-hub/types.d.ts +33 -0
  52. package/dist/context-hub/types.js +1 -0
  53. package/dist/generator/generator.js +39 -6
  54. package/dist/generator/types.d.ts +7 -0
  55. package/dist/generator/writer.d.ts +3 -1
  56. package/dist/generator/writer.js +36 -7
  57. package/dist/importers/confluence.d.ts +5 -0
  58. package/dist/importers/confluence.js +137 -0
  59. package/dist/importers/detect.d.ts +20 -0
  60. package/dist/importers/detect.js +121 -0
  61. package/dist/importers/docusaurus.d.ts +5 -0
  62. package/dist/importers/docusaurus.js +279 -0
  63. package/dist/importers/gitbook.d.ts +5 -0
  64. package/dist/importers/gitbook.js +189 -0
  65. package/dist/importers/github.d.ts +8 -0
  66. package/dist/importers/github.js +99 -0
  67. package/dist/importers/index.d.ts +15 -0
  68. package/dist/importers/index.js +30 -0
  69. package/dist/importers/markdown.d.ts +6 -0
  70. package/dist/importers/markdown.js +105 -0
  71. package/dist/importers/mintlify.d.ts +5 -0
  72. package/dist/importers/mintlify.js +172 -0
  73. package/dist/importers/notion.d.ts +5 -0
  74. package/dist/importers/notion.js +174 -0
  75. package/dist/importers/readme.d.ts +5 -0
  76. package/dist/importers/readme.js +184 -0
  77. package/dist/importers/transform.d.ts +90 -0
  78. package/dist/importers/transform.js +457 -0
  79. package/dist/importers/types.d.ts +37 -0
  80. package/dist/importers/types.js +1 -0
  81. package/dist/llm/anthropic-client.d.ts +1 -0
  82. package/dist/llm/anthropic-client.js +3 -1
  83. package/dist/llm/index.d.ts +6 -4
  84. package/dist/llm/index.js +76 -261
  85. package/dist/llm/openai-client.d.ts +1 -0
  86. package/dist/llm/openai-client.js +7 -2
  87. package/dist/plugins/index.js +7 -0
  88. package/dist/qa/checks.d.ts +10 -0
  89. package/dist/qa/checks.js +492 -0
  90. package/dist/qa/fixes.d.ts +30 -0
  91. package/dist/qa/fixes.js +277 -0
  92. package/dist/qa/index.d.ts +29 -0
  93. package/dist/qa/index.js +187 -0
  94. package/dist/qa/types.d.ts +24 -0
  95. package/dist/qa/types.js +1 -0
  96. package/dist/scanner/csharp.d.ts +23 -0
  97. package/dist/scanner/csharp.js +421 -0
  98. package/dist/scanner/index.js +53 -26
  99. package/dist/scanner/java.d.ts +39 -0
  100. package/dist/scanner/java.js +318 -0
  101. package/dist/scanner/kotlin.d.ts +23 -0
  102. package/dist/scanner/kotlin.js +389 -0
  103. package/dist/scanner/php.d.ts +57 -0
  104. package/dist/scanner/php.js +351 -0
  105. package/dist/scanner/python.js +17 -0
  106. package/dist/scanner/ruby.d.ts +36 -0
  107. package/dist/scanner/ruby.js +431 -0
  108. package/dist/scanner/swift.d.ts +25 -0
  109. package/dist/scanner/swift.js +392 -0
  110. package/dist/scanner/types.d.ts +1 -1
  111. package/dist/template/content/docs/_navigation.json +46 -0
  112. package/dist/template/content/docs/_sidebars.json +684 -0
  113. package/dist/template/content/docs/core.md +4544 -0
  114. package/dist/template/content/docs/index.mdx +89 -0
  115. package/dist/template/content/docs/integrations.md +1158 -0
  116. package/dist/template/content/docs/llms-full.md +403 -0
  117. package/dist/template/content/docs/llms.txt +4588 -0
  118. package/dist/template/content/docs/other.md +10379 -0
  119. package/dist/template/content/docs/tools.md +746 -0
  120. package/dist/template/content/docs/types.md +531 -0
  121. package/dist/template/docs.json +13 -11
  122. package/dist/template/mdx-components.tsx +27 -2
  123. package/dist/template/package.json +6 -0
  124. package/dist/template/public/search-index.json +1 -1
  125. package/dist/template/scripts/build-search-index.mjs +149 -13
  126. package/dist/template/src/app/api/chat/route.ts +83 -128
  127. package/dist/template/src/app/docs/[...slug]/page.tsx +75 -20
  128. package/dist/template/src/app/docs/llms-full.md +151 -4
  129. package/dist/template/src/app/docs/llms.txt +2464 -847
  130. package/dist/template/src/app/docs/page.mdx +48 -38
  131. package/dist/template/src/app/layout.tsx +3 -1
  132. package/dist/template/src/app/page.tsx +22 -8
  133. package/dist/template/src/components/ai-chat.tsx +73 -64
  134. package/dist/template/src/components/breadcrumbs.tsx +21 -23
  135. package/dist/template/src/components/copy-button.tsx +13 -9
  136. package/dist/template/src/components/copy-page-button.tsx +54 -0
  137. package/dist/template/src/components/docs-layout.tsx +37 -25
  138. package/dist/template/src/components/header.tsx +51 -10
  139. package/dist/template/src/components/mdx/card.tsx +17 -3
  140. package/dist/template/src/components/mdx/code-block.tsx +13 -9
  141. package/dist/template/src/components/mdx/code-group.tsx +13 -8
  142. package/dist/template/src/components/mdx/heading.tsx +15 -2
  143. package/dist/template/src/components/mdx/highlighted-code.tsx +13 -8
  144. package/dist/template/src/components/mdx/index.tsx +2 -0
  145. package/dist/template/src/components/mdx/mermaid.tsx +110 -0
  146. package/dist/template/src/components/mdx/screenshot.tsx +150 -0
  147. package/dist/template/src/components/scroll-to-hash.tsx +48 -0
  148. package/dist/template/src/components/sidebar.tsx +12 -18
  149. package/dist/template/src/components/table-of-contents.tsx +9 -0
  150. package/dist/template/src/lib/highlight.ts +3 -88
  151. package/dist/template/src/lib/navigation.ts +159 -0
  152. package/dist/template/src/lib/search-types.ts +4 -1
  153. package/dist/template/src/lib/search.ts +30 -7
  154. package/dist/template/src/styles/globals.css +17 -6
  155. package/dist/utils/files.d.ts +9 -1
  156. package/dist/utils/files.js +59 -10
  157. package/dist/utils/validation.d.ts +0 -3
  158. package/dist/utils/validation.js +0 -26
  159. package/package.json +5 -1
@@ -0,0 +1,531 @@
1
+ ---
2
+ title: "Types & Interfaces"
3
+ description: "Type definitions and interfaces"
4
+ ---
5
+
6
+ <CardGroup cols={2}>
7
+ <Card title="TypeScriptScanner" icon="cube" href="#typescriptscanner">
8
+ Scans TS/JS source files
9
+ </Card>
10
+ <Card title="canHandle" icon="code" href="#canhandle">
11
+ Checks file scanner compatibility
12
+ </Card>
13
+ <Card title="scanFile" icon="code" href="#scanfile">
14
+ Extracts API elements from files
15
+ </Card>
16
+ </CardGroup>
17
+
18
+
19
+ ## `TypeScriptScanner`
20
+
21
+ ```typescript
22
+ class TypeScriptScanner implements Scanner
23
+ ```
24
+
25
+ Use this to scan TypeScript and JavaScript source files and extract API elements (functions, classes, parameters, and metadata) for automated documentation generation.
26
+
27
+ `TypeScriptScanner` implements the `Scanner` interface and uses the TypeScript compiler API to parse and analyze `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, and `.cjs` files. It skips declaration files (`.d.ts`) automatically.
28
+
29
+ ## Properties
30
+
31
+ | Property | Type | Description |
32
+ |----------|------|-------------|
33
+ | `languages` | `string[]` | Always `['typescript', 'javascript']` — the languages this scanner supports |
34
+
35
+ ## Methods
36
+
37
+ ### `canHandle(filePath: string): boolean`
38
+
39
+ | Parameter | Type | Required | Description |
40
+ |-----------|------|----------|-------------|
41
+ | `filePath` | `string` | ✅ | Absolute or relative path to the file to check |
42
+
43
+ **Returns:** `true` if the file has a supported extension (`.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`) **and** is not a `.d.ts` declaration file. Use this before calling `scanFile` to avoid unsupported file errors.
44
+
45
+ ---
46
+
47
+ ### `scanFile(filePath: string): Promise<ScanResult>`
48
+
49
+ | Parameter | Type | Required | Description |
50
+ |-----------|------|----------|-------------|
51
+ | `filePath` | `string` | ✅ | Path to the source file to scan and parse |
52
+
53
+ **Returns:** A `Promise<ScanResult>` containing:
54
+ - `language` — `'typescript'` for `.ts`/`.tsx` files, `'javascript'` for all others
55
+ - `elements` — Array of `APIElement` objects representing discovered functions, classes, interfaces, and their parameters
56
+ - `filePath` — The original file path passed in
57
+
58
+ **Throws:** If the file cannot be read from disk or the TypeScript compiler fails to parse it.
59
+
60
+ ## Notes
61
+ - Declaration files (`.d.ts`) are explicitly excluded from scanning even though they use the `.ts` extension
62
+ - The scanner reads files synchronously from disk before parsing — ensure the file exists before calling `scanFile`
63
+ - Best used as part of a pipeline: call `canHandle` first, then `scanFile` only on supported files
64
+
65
+ ### Example
66
+
67
+ ```typescript example.ts
68
+ // ─── Inline types (mirrors the real Scanner/ScanResult interface) ───────────
69
+
70
+ type Parameter = {
71
+ name: string
72
+ type: string
73
+ required: boolean
74
+ description?: string
75
+ }
76
+
77
+ type APIElement = {
78
+ name: string
79
+ kind: 'function' | 'class' | 'interface' | 'method' | 'variable'
80
+ parameters?: Parameter[]
81
+ returnType?: string
82
+ description?: string
83
+ }
84
+
85
+ type ScanResult = {
86
+ filePath: string
87
+ language: string
88
+ elements: APIElement[]
89
+ }
90
+
91
+ // ─── Simulated TypeScriptScanner (self-contained, no external imports) ───────
92
+
93
+ class TypeScriptScanner {
94
+ languages = ['typescript', 'javascript']
95
+
96
+ canHandle(filePath: string): boolean {
97
+ return /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath) && !filePath.includes('.d.ts')
98
+ }
99
+
100
+ async scanFile(filePath: string): Promise<ScanResult> {
101
+ const language =
102
+ filePath.endsWith('.ts') || filePath.endsWith('.tsx') ? 'typescript' : 'javascript'
103
+
104
+ // Simulated parse result — in production this uses the TypeScript compiler API
105
+ const simulatedElements: APIElement[] = [
106
+ {
107
+ name: 'createUser',
108
+ kind: 'function',
109
+ parameters: [
110
+ { name: 'username', type: 'string', required: true, description: 'Unique username' },
111
+ { name: 'email', type: 'string', required: true, description: 'User email address' },
112
+ { name: 'role', type: 'string', required: false, description: 'Optional user role' },
113
+ ],
114
+ returnType: 'Promise<User>',
115
+ description: 'Creates a new user account',
116
+ },
117
+ {
118
+ name: 'UserService',
119
+ kind: 'class',
120
+ description: 'Handles all user-related operations',
121
+ },
122
+ ]
123
+
124
+ return {
125
+ filePath,
126
+ language,
127
+ elements: simulatedElements,
128
+ }
129
+ }
130
+ }
131
+
132
+ // ─── Usage example ────────────────────────────────────────────────────────────
133
+
134
+ const scanner = new TypeScriptScanner()
135
+
136
+ const filesToCheck = [
137
+ 'src/services/userService.ts',
138
+ 'src/utils/helpers.js',
139
+ 'src/types/models.d.ts', // ← should be skipped
140
+ 'src/config/settings.json', // ← should be skipped
141
+ ]
142
+
143
+ async function main() {
144
+ try {
145
+ console.log('Supported languages:', scanner.languages)
146
+ // Output: Supported languages: [ 'typescript', 'javascript' ]
147
+
148
+ for (const file of filesToCheck) {
149
+ const supported = scanner.canHandle(file)
150
+ console.log(`\ncanHandle('${file}') → ${supported}`)
151
+
152
+ if (!supported) {
153
+ console.log(' ↳ Skipping unsupported or declaration file')
154
+ continue
155
+ }
156
+
157
+ const result = await scanner.scanFile(file)
158
+
159
+ console.log(` ↳ Language : ${result.language}`)
160
+ console.log(` ↳ Elements found: ${result.elements.length}`)
161
+
162
+ for (const el of result.elements) {
163
+ console.log(` • [${el.kind}] ${el.name}`)
164
+ if (el.parameters && el.parameters.length > 0) {
165
+ for (const param of el.parameters) {
166
+ const req = param.required ? 'required' : 'optional'
167
+ console.log(` - ${param.name}: ${param.type} (${req})`)
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ // Expected output for userService.ts:
174
+ // canHandle('src/services/userService.ts') → true
175
+ // ↳ Language : typescript
176
+ // ↳ Elements found: 2
177
+ // • [function] createUser
178
+ // - username: string (required)
179
+ // - email: string (required)
180
+ // - role: string (optional)
181
+ // • [class] UserService
182
+
183
+ } catch (error) {
184
+ console.error('Scanner failed:', error instanceof Error ? error.message : error)
185
+ process.exit(1)
186
+ }
187
+ }
188
+
189
+ main()
190
+ ```
191
+
192
+ ### Related
193
+
194
+ <CardGroup cols={3}>
195
+ <Card title="canHandle" icon="link" href="#canhandle">
196
+ Uses
197
+ </Card>
198
+ <Card title="scanFile" icon="link" href="#scanfile">
199
+ Uses
200
+ </Card>
201
+ <Card title="canHandle" icon="link" href="#canhandle">
202
+ Used by
203
+ </Card>
204
+ </CardGroup>
205
+
206
+ ---
207
+
208
+
209
+ ## `canHandle`
210
+
211
+ ```typescript
212
+ canHandle(filePath: string): boolean
213
+ ```
214
+
215
+ Use this to quickly determine whether a file path is a TypeScript/JavaScript source file that the scanner can process — filtering out declaration files (`.d.ts`) automatically.
216
+
217
+ Returns `true` for `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, and `.cjs` files. Returns `false` for `.d.ts` declaration files and any other file types.
218
+
219
+ ### Parameters
220
+
221
+ | Name | Type | Required | Description |
222
+ |------|------|----------|-------------|
223
+ | `filePath` | `string` | ✅ | The file path (relative or absolute) to check for scanner compatibility |
224
+
225
+ ### Returns
226
+
227
+ | Value | Condition |
228
+ |-------|-----------|
229
+ | `true` | File ends with `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, or `.cjs` — and is **not** a `.d.ts` declaration file |
230
+ | `false` | File is a `.d.ts` declaration file, or has any other extension (`.py`, `.json`, `.md`, etc.) |
231
+
232
+ ### Notes
233
+ - Declaration files (`.d.ts`) are explicitly excluded even though they end in `.ts`
234
+ - Both relative paths (`./src/index.ts`) and absolute paths (`/home/user/project/app.js`) are supported
235
+ - Only the file extension is evaluated — the file does not need to exist on disk
236
+
237
+ ### Example
238
+
239
+ ```typescript example.ts
240
+ // Inline implementation matching TypeScriptScanner.canHandle behavior
241
+ class TypeScriptScanner {
242
+ languages = ['typescript', 'javascript']
243
+
244
+ canHandle(filePath: string): boolean {
245
+ return /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath) && !filePath.includes('.d.ts')
246
+ }
247
+ }
248
+
249
+ const scanner = new TypeScriptScanner()
250
+
251
+ const testFiles = [
252
+ // Expected: true
253
+ { path: 'src/index.ts', expected: true },
254
+ { path: 'src/components/Button.tsx', expected: true },
255
+ { path: 'dist/bundle.js', expected: true },
256
+ { path: 'src/App.jsx', expected: true },
257
+ { path: 'server/loader.mjs', expected: true },
258
+ { path: 'legacy/module.cjs', expected: true },
259
+
260
+ // Expected: false — declaration files are excluded
261
+ { path: 'dist/index.d.ts', expected: false },
262
+ { path: 'types/global.d.ts', expected: false },
263
+
264
+ // Expected: false — unsupported extensions
265
+ { path: 'README.md', expected: false },
266
+ { path: 'config/settings.json', expected: false },
267
+ { path: 'scripts/build.py', expected: false },
268
+ ]
269
+
270
+ console.log('TypeScriptScanner.canHandle() results:\n')
271
+
272
+ let allPassed = true
273
+
274
+ for (const { path, expected } of testFiles) {
275
+ const result = scanner.canHandle(path)
276
+ const status = result === expected ? '✅ PASS' : '❌ FAIL'
277
+ if (result !== expected) allPassed = false
278
+
279
+ console.log(`${status} canHandle("${path}") => ${result}`)
280
+ }
281
+
282
+ console.log(`\nAll tests passed: ${allPassed}`)
283
+
284
+ // Expected output:
285
+ // ✅ PASS canHandle("src/index.ts") => true
286
+ // ✅ PASS canHandle("src/components/Button.tsx") => true
287
+ // ✅ PASS canHandle("dist/bundle.js") => true
288
+ // ✅ PASS canHandle("src/App.jsx") => true
289
+ // ✅ PASS canHandle("server/loader.mjs") => true
290
+ // ✅ PASS canHandle("legacy/module.cjs") => true
291
+ // ✅ PASS canHandle("dist/index.d.ts") => false
292
+ // ✅ PASS canHandle("types/global.d.ts") => false
293
+ // ✅ PASS canHandle("README.md") => false
294
+ // ✅ PASS canHandle("config/settings.json") => false
295
+ // ✅ PASS canHandle("scripts/build.py") => false
296
+ //
297
+ // All tests passed: true
298
+ ```
299
+
300
+ ### Related
301
+
302
+ <CardGroup cols={3}>
303
+ <Card title="GoScanner" icon="link" href="/docs/other#goscanner">
304
+ Uses
305
+ </Card>
306
+ <Card title="scanFile" icon="link" href="#scanfile">
307
+ Uses
308
+ </Card>
309
+ <Card title="scanFile" icon="link" href="#scanfile">
310
+ Uses
311
+ </Card>
312
+ <Card title="PythonScanner" icon="link" href="/docs/other#pythonscanner">
313
+ Uses
314
+ </Card>
315
+ <Card title="scanFile" icon="link" href="#scanfile">
316
+ Uses
317
+ </Card>
318
+ <Card title="RustScanner" icon="link" href="/docs/other#rustscanner">
319
+ Uses
320
+ </Card>
321
+ </CardGroup>
322
+
323
+ ---
324
+
325
+
326
+ ## `scanFile`
327
+
328
+ ```typescript
329
+ async scanFile(filePath: string): Promise<ScanResult>
330
+ ```
331
+
332
+ Use this to extract API elements (functions, classes, methods, parameters) from a TypeScript or JavaScript source file for documentation generation or code analysis.
333
+
334
+ `scanFile` parses a `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, or `.cjs` file and returns a structured `ScanResult` containing all discovered API elements. It automatically detects whether to treat the file as TypeScript or JavaScript based on the file extension.
335
+
336
+ > **Note:** Does not handle `.d.ts` declaration files — use `canHandle()` to pre-check a file path before scanning.
337
+
338
+ ## Parameters
339
+
340
+ | Name | Type | Required | Description |
341
+ |------|------|----------|-------------|
342
+ | `filePath` | `string` | ✅ | Absolute or relative path to the source file to scan. Must be a `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, or `.cjs` file. |
343
+
344
+ ## Returns
345
+
346
+ Returns `Promise<ScanResult>` — resolves with a structured object containing:
347
+
348
+ | Field | Type | Description |
349
+ |-------|------|-------------|
350
+ | `filePath` | `string` | The path of the scanned file |
351
+ | `language` | `'typescript' \| 'javascript'` | Detected language based on file extension |
352
+ | `elements` | `APIElement[]` | All discovered functions, classes, methods, and their parameters |
353
+ | `error?` | `string` | Present if the file could not be parsed; `elements` will be empty |
354
+
355
+ **Throws:** Does not throw — errors are captured and returned in the `ScanResult.error` field.
356
+
357
+ ### Example
358
+
359
+ ```typescript example.ts
360
+ import { readFileSync, writeFileSync, unlinkSync } from 'fs'
361
+ import { join } from 'path'
362
+
363
+ // --- Inline types (mirrors the real ScanResult shape) ---
364
+ type Parameter = {
365
+ name: string
366
+ type: string
367
+ required: boolean
368
+ description?: string
369
+ }
370
+
371
+ type APIElement = {
372
+ name: string
373
+ kind: 'function' | 'class' | 'method' | 'interface'
374
+ parameters: Parameter[]
375
+ returnType?: string
376
+ description?: string
377
+ isExported: boolean
378
+ }
379
+
380
+ type ScanResult = {
381
+ filePath: string
382
+ language: 'typescript' | 'javascript'
383
+ elements: APIElement[]
384
+ error?: string
385
+ }
386
+
387
+ // --- Simulated TypeScriptScanner (self-contained, no external imports) ---
388
+ class TypeScriptScanner {
389
+ canHandle(filePath: string): boolean {
390
+ return /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath) && !filePath.includes('.d.ts')
391
+ }
392
+
393
+ async scanFile(filePath: string): Promise<ScanResult> {
394
+ const language =
395
+ filePath.endsWith('.ts') || filePath.endsWith('.tsx') ? 'typescript' : 'javascript'
396
+
397
+ try {
398
+ const source = readFileSync(filePath, 'utf-8')
399
+
400
+ // Simplified regex-based extraction for demonstration
401
+ const elements: APIElement[] = []
402
+
403
+ // Match exported functions: export function name(params): ReturnType
404
+ const fnRegex = /export\s+(async\s+)?function\s+(\w+)\s*\(([^)]*)\)\s*(?::\s*([\w<>\[\]|]+))?/g
405
+ let match: RegExpExecArray | null
406
+
407
+ while ((match = fnRegex.exec(source)) !== null) {
408
+ const [, , name, rawParams, returnType] = match
409
+
410
+ const parameters: Parameter[] = rawParams
411
+ .split(',')
412
+ .map((p) => p.trim())
413
+ .filter(Boolean)
414
+ .map((p) => {
415
+ const [paramName, paramType] = p.split(':').map((s) => s.trim())
416
+ const required = !paramName.includes('?')
417
+ return {
418
+ name: paramName.replace('?', ''),
419
+ type: paramType || 'unknown',
420
+ required,
421
+ }
422
+ })
423
+
424
+ elements.push({
425
+ name,
426
+ kind: 'function',
427
+ parameters,
428
+ returnType: returnType || 'void',
429
+ isExported: true,
430
+ })
431
+ }
432
+
433
+ return { filePath, language, elements }
434
+ } catch (err) {
435
+ return {
436
+ filePath,
437
+ language,
438
+ elements: [],
439
+ error: err instanceof Error ? err.message : 'Unknown error',
440
+ }
441
+ }
442
+ }
443
+ }
444
+
445
+ // --- Demo: create a temp file and scan it ---
446
+ async function main() {
447
+ const scanner = new TypeScriptScanner()
448
+ const tempFile = join(process.cwd(), '_demo_scan_target.ts')
449
+
450
+ // Write a sample TypeScript file to scan
451
+ const sampleSource = `
452
+ export async function fetchUser(userId: string, includeProfile?: boolean): Promise<User> {
453
+ return db.users.find(userId)
454
+ }
455
+
456
+ export function formatDate(date: Date, locale: string): string {
457
+ return date.toLocaleDateString(locale)
458
+ }
459
+ `
460
+ writeFileSync(tempFile, sampleSource, 'utf-8')
461
+
462
+ try {
463
+ // Guard: only scan supported file types
464
+ if (!scanner.canHandle(tempFile)) {
465
+ console.error('File type not supported:', tempFile)
466
+ return
467
+ }
468
+
469
+ const result = await scanner.scanFile(tempFile)
470
+
471
+ if (result.error) {
472
+ console.error('Scan failed:', result.error)
473
+ return
474
+ }
475
+
476
+ console.log('Language detected:', result.language)
477
+ // Output: Language detected: typescript
478
+
479
+ console.log('Elements found:', result.elements.length)
480
+ // Output: Elements found: 2
481
+
482
+ for (const el of result.elements) {
483
+ console.log(`\n[${el.kind}] ${el.name} → ${el.returnType}`)
484
+ for (const param of el.parameters) {
485
+ console.log(` param: ${param.name} (${param.type}) required=${param.required}`)
486
+ }
487
+ }
488
+ // Output:
489
+ // [function] fetchUser → Promise<User>
490
+ // param: userId (string) required=true
491
+ // param: includeProfile (boolean) required=false
492
+ //
493
+ // [function] formatDate → string
494
+ // param: date (Date) required=true
495
+ // param: locale (string) required=true
496
+
497
+ } catch (error) {
498
+ console.error('Unexpected error during scan:', error)
499
+ } finally {
500
+ unlinkSync(tempFile) // clean up temp file
501
+ }
502
+ }
503
+
504
+ main()
505
+ ```
506
+
507
+ ### Related
508
+
509
+ <CardGroup cols={3}>
510
+ <Card title="canHandle" icon="link" href="#canhandle">
511
+ Uses
512
+ </Card>
513
+ <Card title="canHandle" icon="link" href="#canhandle">
514
+ Uses
515
+ </Card>
516
+ <Card title="canHandle" icon="link" href="#canhandle">
517
+ Uses
518
+ </Card>
519
+ <Card title="canHandle" icon="link" href="#canhandle">
520
+ Uses
521
+ </Card>
522
+ <Card title="GoScanner" icon="link" href="/docs/other#goscanner">
523
+ Used by
524
+ </Card>
525
+ <Card title="canHandle" icon="link" href="#canhandle">
526
+ Used by
527
+ </Card>
528
+ </CardGroup>
529
+
530
+ ---
531
+
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "API Documentation",
3
- "description": "Documentation generated with Skrypt",
2
+ "name": "Skrypt",
3
+ "description": "AI-powered documentation generation",
4
4
  "theme": {
5
5
  "primaryColor": "#3b82f6",
6
6
  "accentColor": "#8b5cf6",
@@ -8,26 +8,28 @@
8
8
  },
9
9
  "navigation": [
10
10
  {
11
- "group": "Getting Started",
11
+ "group": "Overview",
12
+ "icon": "BookOpen",
12
13
  "pages": [
13
- { "title": "Introduction", "path": "/docs" },
14
- { "title": "Installation", "path": "/docs/installation" },
15
- { "title": "Quick Start", "path": "/docs/quickstart" }
14
+ { "title": "Introduction", "path": "/docs" }
16
15
  ]
17
16
  },
18
17
  {
19
18
  "group": "API Reference",
19
+ "icon": "Code",
20
20
  "pages": [
21
- { "title": "Overview", "path": "/docs/api" },
22
- { "title": "Authentication", "path": "/docs/api/auth" },
23
- { "title": "Endpoints", "path": "/docs/api/endpoints" }
21
+ { "title": "Core API", "path": "/docs/core" },
22
+ { "title": "Tools & Utilities", "path": "/docs/tools" },
23
+ { "title": "Types & Interfaces", "path": "/docs/types" },
24
+ { "title": "Integrations", "path": "/docs/integrations" },
25
+ { "title": "Other", "path": "/docs/other" }
24
26
  ]
25
27
  }
26
28
  ],
27
29
  "footer": {
28
30
  "links": [
29
- { "title": "GitHub", "url": "https://github.com" },
30
- { "title": "Discord", "url": "https://discord.com" }
31
+ { "title": "GitHub", "url": "https://github.com/debgotwired/skrypt" },
32
+ { "title": "npm", "url": "https://www.npmjs.com/package/skrypt-ai" }
31
33
  ]
32
34
  }
33
35
  }
@@ -1,4 +1,5 @@
1
1
  import type { MDXComponents } from 'mdx/types'
2
+ import { Children, isValidElement, type ReactNode } from 'react'
2
3
  import {
3
4
  Card,
4
5
  CardGroup,
@@ -26,8 +27,31 @@ import {
26
27
  H4,
27
28
  ParamTable,
28
29
  Schema,
30
+ Mermaid,
29
31
  } from '@/components/mdx'
30
32
 
33
+ /** Wrapper for <pre> that routes mermaid code blocks to the Mermaid component */
34
+ function PreWithMermaid(props: { children: ReactNode; className?: string }) {
35
+ let isMermaid = false
36
+ let codeText = ''
37
+
38
+ Children.forEach(props.children, (child) => {
39
+ if (isValidElement(child) && child.type === 'code') {
40
+ const childProps = child.props as { className?: string; children?: string }
41
+ if (childProps.className?.includes('language-mermaid')) {
42
+ isMermaid = true
43
+ codeText = childProps.children || ''
44
+ }
45
+ }
46
+ })
47
+
48
+ if (isMermaid) {
49
+ return <Mermaid chart={codeText} />
50
+ }
51
+
52
+ return <HighlightedCode {...props} />
53
+ }
54
+
31
55
  export function useMDXComponents(components: MDXComponents): MDXComponents {
32
56
  return {
33
57
  // Custom components
@@ -51,8 +75,9 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
51
75
  Step,
52
76
  ParamTable,
53
77
  Schema,
54
- // Override default elements - use syntax-highlighted code
55
- pre: HighlightedCode,
78
+ Mermaid,
79
+ // Override default elements - use syntax-highlighted code (with mermaid routing)
80
+ pre: PreWithMermaid,
56
81
  h1: H1,
57
82
  h2: H2,
58
83
  h3: H3,
@@ -10,6 +10,9 @@
10
10
  "start": "next start"
11
11
  },
12
12
  "dependencies": {
13
+ "@ai-sdk/anthropic": "^1.0.0",
14
+ "@ai-sdk/openai": "^1.0.0",
15
+ "@ai-sdk/react": "^1.0.0",
13
16
  "@codesandbox/sandpack-react": "^2.20.0",
14
17
  "@mdx-js/loader": "^3.1.0",
15
18
  "@mdx-js/react": "^3.1.0",
@@ -19,13 +22,16 @@
19
22
  "clsx": "^2.1.0",
20
23
  "gray-matter": "^4.0.3",
21
24
  "lucide-react": "^0.500.0",
25
+ "mermaid": "^11.13.0",
22
26
  "next": "^15.3.0",
23
27
  "next-mdx-remote": "^6.0.0",
24
28
  "react": "^19.0.0",
25
29
  "react-dom": "^19.0.0",
26
30
  "remark-frontmatter": "^5.0.0",
27
31
  "remark-gfm": "^4.0.0",
32
+ "ai": "^4.0.0",
28
33
  "shiki": "^3.0.0",
34
+ "streamdown": "^1.0.0",
29
35
  "tailwind-merge": "^3.0.0",
30
36
  "yaml": "^2.8.2"
31
37
  },