skrypt-ai 0.5.0 → 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 (120) hide show
  1. package/dist/auth/index.js +8 -1
  2. package/dist/autofix/index.d.ts +0 -4
  3. package/dist/autofix/index.js +0 -21
  4. package/dist/capture/browser.d.ts +11 -0
  5. package/dist/capture/browser.js +173 -0
  6. package/dist/capture/diff.d.ts +23 -0
  7. package/dist/capture/diff.js +52 -0
  8. package/dist/capture/index.d.ts +23 -0
  9. package/dist/capture/index.js +210 -0
  10. package/dist/capture/naming.d.ts +17 -0
  11. package/dist/capture/naming.js +45 -0
  12. package/dist/capture/parser.d.ts +15 -0
  13. package/dist/capture/parser.js +80 -0
  14. package/dist/capture/types.d.ts +57 -0
  15. package/dist/capture/types.js +1 -0
  16. package/dist/cli.js +4 -0
  17. package/dist/commands/autofix.js +136 -120
  18. package/dist/commands/cron.js +58 -47
  19. package/dist/commands/deploy.js +123 -102
  20. package/dist/commands/generate.js +88 -6
  21. package/dist/commands/heal.d.ts +10 -0
  22. package/dist/commands/heal.js +201 -0
  23. package/dist/commands/i18n.js +146 -111
  24. package/dist/commands/lint.js +50 -44
  25. package/dist/commands/llms-txt.js +59 -49
  26. package/dist/commands/login.js +61 -43
  27. package/dist/commands/mcp.js +6 -0
  28. package/dist/commands/monitor.js +13 -8
  29. package/dist/commands/qa.d.ts +2 -0
  30. package/dist/commands/qa.js +43 -0
  31. package/dist/commands/review-pr.js +108 -102
  32. package/dist/commands/sdk.js +128 -122
  33. package/dist/commands/security.js +86 -80
  34. package/dist/commands/test.js +91 -92
  35. package/dist/commands/version.js +104 -75
  36. package/dist/commands/watch.js +130 -114
  37. package/dist/config/types.js +2 -2
  38. package/dist/context-hub/index.d.ts +23 -0
  39. package/dist/context-hub/index.js +179 -0
  40. package/dist/context-hub/mappings.d.ts +8 -0
  41. package/dist/context-hub/mappings.js +55 -0
  42. package/dist/context-hub/types.d.ts +33 -0
  43. package/dist/context-hub/types.js +1 -0
  44. package/dist/generator/generator.js +39 -6
  45. package/dist/generator/types.d.ts +7 -0
  46. package/dist/generator/writer.d.ts +3 -1
  47. package/dist/generator/writer.js +24 -4
  48. package/dist/llm/anthropic-client.d.ts +1 -0
  49. package/dist/llm/anthropic-client.js +3 -1
  50. package/dist/llm/index.d.ts +6 -4
  51. package/dist/llm/index.js +76 -261
  52. package/dist/llm/openai-client.d.ts +1 -0
  53. package/dist/llm/openai-client.js +7 -2
  54. package/dist/qa/checks.d.ts +10 -0
  55. package/dist/qa/checks.js +492 -0
  56. package/dist/qa/fixes.d.ts +30 -0
  57. package/dist/qa/fixes.js +277 -0
  58. package/dist/qa/index.d.ts +29 -0
  59. package/dist/qa/index.js +187 -0
  60. package/dist/qa/types.d.ts +24 -0
  61. package/dist/qa/types.js +1 -0
  62. package/dist/scanner/csharp.d.ts +23 -0
  63. package/dist/scanner/csharp.js +421 -0
  64. package/dist/scanner/index.js +16 -2
  65. package/dist/scanner/java.d.ts +39 -0
  66. package/dist/scanner/java.js +318 -0
  67. package/dist/scanner/kotlin.d.ts +23 -0
  68. package/dist/scanner/kotlin.js +389 -0
  69. package/dist/scanner/php.d.ts +57 -0
  70. package/dist/scanner/php.js +351 -0
  71. package/dist/scanner/ruby.d.ts +36 -0
  72. package/dist/scanner/ruby.js +431 -0
  73. package/dist/scanner/swift.d.ts +25 -0
  74. package/dist/scanner/swift.js +392 -0
  75. package/dist/scanner/types.d.ts +1 -1
  76. package/dist/template/content/docs/_navigation.json +46 -0
  77. package/dist/template/content/docs/_sidebars.json +684 -0
  78. package/dist/template/content/docs/core.md +4544 -0
  79. package/dist/template/content/docs/index.mdx +89 -0
  80. package/dist/template/content/docs/integrations.md +1158 -0
  81. package/dist/template/content/docs/llms-full.md +403 -0
  82. package/dist/template/content/docs/llms.txt +4588 -0
  83. package/dist/template/content/docs/other.md +10379 -0
  84. package/dist/template/content/docs/tools.md +746 -0
  85. package/dist/template/content/docs/types.md +531 -0
  86. package/dist/template/docs.json +13 -11
  87. package/dist/template/mdx-components.tsx +27 -2
  88. package/dist/template/package.json +6 -0
  89. package/dist/template/public/search-index.json +1 -1
  90. package/dist/template/scripts/build-search-index.mjs +84 -6
  91. package/dist/template/src/app/api/chat/route.ts +83 -128
  92. package/dist/template/src/app/docs/[...slug]/page.tsx +75 -20
  93. package/dist/template/src/app/docs/llms-full.md +151 -4
  94. package/dist/template/src/app/docs/llms.txt +2464 -847
  95. package/dist/template/src/app/docs/page.mdx +48 -38
  96. package/dist/template/src/app/layout.tsx +3 -1
  97. package/dist/template/src/app/page.tsx +22 -8
  98. package/dist/template/src/components/ai-chat.tsx +73 -64
  99. package/dist/template/src/components/breadcrumbs.tsx +21 -23
  100. package/dist/template/src/components/copy-button.tsx +13 -9
  101. package/dist/template/src/components/copy-page-button.tsx +54 -0
  102. package/dist/template/src/components/docs-layout.tsx +37 -25
  103. package/dist/template/src/components/header.tsx +51 -10
  104. package/dist/template/src/components/mdx/card.tsx +17 -3
  105. package/dist/template/src/components/mdx/code-block.tsx +13 -9
  106. package/dist/template/src/components/mdx/code-group.tsx +13 -8
  107. package/dist/template/src/components/mdx/heading.tsx +15 -2
  108. package/dist/template/src/components/mdx/highlighted-code.tsx +13 -8
  109. package/dist/template/src/components/mdx/index.tsx +2 -0
  110. package/dist/template/src/components/mdx/mermaid.tsx +110 -0
  111. package/dist/template/src/components/mdx/screenshot.tsx +150 -0
  112. package/dist/template/src/components/scroll-to-hash.tsx +48 -0
  113. package/dist/template/src/components/sidebar.tsx +12 -18
  114. package/dist/template/src/components/table-of-contents.tsx +9 -0
  115. package/dist/template/src/lib/highlight.ts +3 -88
  116. package/dist/template/src/lib/navigation.ts +159 -0
  117. package/dist/template/src/styles/globals.css +17 -6
  118. package/dist/utils/validation.d.ts +0 -3
  119. package/dist/utils/validation.js +0 -26
  120. package/package.json +3 -2
@@ -0,0 +1,4588 @@
1
+ # Skrypt
2
+
3
+ > API documentation for Skrypt
4
+
5
+ ## Overview
6
+
7
+ This project contains 130 documented API elements across 28 modules.
8
+
9
+ ## Quick Reference
10
+
11
+ ### index
12
+
13
+ - `getAuthConfig`: function - Use this to synchronously retrieve the current authentication configuration from environment variabl
14
+ - `getAuthConfigAsync`: function - Use this to retrieve the current user's authentication configuration in any CLI command action
15
+ - `saveAuthConfig`: function - Use this to persist authentication configuration (API keys, endpoints, tokens) to a secure local con
16
+ - `clearAuth`: function - Use this to completely sign out a user by wiping all stored authentication credentials — both from t
17
+ - `getKeyStorageMethod`: function - Use this to detect where an API key is currently stored, so you can display storage status to users,
18
+ - `checkPlan`: function - Use this to verify an API key's validity and retrieve the associated subscription plan details befor
19
+ - `requirePro`: function - Use this to gate CLI commands behind a Pro subscription, automatically printing upgrade instructions
20
+ - `autoFixExample`: function - Use this to automatically repair broken or invalid code examples by iteratively applying LLM-powered
21
+ - `autoFixBatch`: function - Use this to automatically fix multiple broken code examples in a single batch operation, getting bac
22
+ - `createTypeScriptValidator`: function - Use this to validate TypeScript code strings at runtime — perfect for checking LLM-generated code, u
23
+ - `createPythonValidator`: function - Use this to validate Python code syntax before executing or storing it — catches syntax errors witho
24
+ - `runImport`: function - Use this to automatically import and process a documentation directory based on its detected format
25
+ - `createLLMClient`: function - Use this to initialize a typed LLM client for a specific AI provider (OpenAI, Anthropic, etc.) with
26
+ - `generateDocumentation`: function - Use this to automatically generate documentation for a code element (function, class, method, etc.)
27
+ - `fixCodeSample`: function - Use this to automatically repair broken code samples by sending them to an LLM with the error contex
28
+ - `PluginManager`: class - Use this to load, manage, and execute documentation plugins that transform source files into output
29
+ - `constructor`: method - Use this to initialize a plugin manager that coordinates documentation plugins across a source codeb
30
+ - `loadPlugins`: method - Use this to initialize and load plugins into the `PluginManager` from a configuration file, enabling
31
+ - `register`: method - Use this to manually register a plugin with the `PluginManager`, adding it to the active plugin list
32
+ - `runHook`: method - Use this to execute a named hook across all registered plugins in sequence, passing data through eac
33
+ - `onInit`: method - Use this to trigger the initialization lifecycle hook across all registered plugins in a `PluginMana
34
+ - `onBeforeScan`: method - Use this to trigger all registered plugins' pre-scan lifecycle hooks before a documentation scan beg
35
+ - `onAfterScan`: method - Use this to run all registered plugins' `onAfterScan` hooks against a list of scanned elements, allo
36
+ - `onBeforeGenerate`: method - Use this to run all registered plugins' `onBeforeGenerate` hooks against a collection of elements be
37
+ - `onAfterGenerate`: method - Use this to run all registered plugins' `onAfterGenerate` hooks against a collection of generated do
38
+ - `onBeforeWrite`: method - Use this to run all registered plugins' `onBeforeWrite` hooks against your generated docs array, all
39
+ - `onAfterWrite`: method - Use this to trigger all registered plugin hooks after documentation has been written to disk — ideal
40
+ - `transformContent`: method - Use this to pipe file content through a chain of registered plugins, each of which can modify the co
41
+ - `definePlugin`: function - Use this to define a typed plugin configuration object for the Skrypt plugin system with full type s
42
+ - `scanDirectory`: function - Use this to recursively scan a directory (or single file) for all API elements — functions, classes,
43
+ - `scanFile`: function - Use this to extract structured metadata from a single source file — functions, classes, types, and o
44
+
45
+ ### keychain
46
+
47
+ - `keychainAvailable`: function - Use this to check whether the system keychain is available and functional before attempting to store
48
+ - `keychainStore`: function - Use this to securely store an API key or secret in the operating system's native keychain (macOS Key
49
+ - `keychainRetrieve`: function - Use this to securely retrieve a stored API key or password from the operating system's native keycha
50
+ - `keychainDelete`: function - Use this to securely delete a stored password/credential from the system keychain
51
+ - `getKeychainPlatformName`: function - Use this to display a human-readable name for the current platform's credential storage system in us
52
+
53
+ ### notices
54
+
55
+ - `hasSeenNotice`: function - Use this to check whether a user has already acknowledged a specific notice, warning, or announcemen
56
+ - `markNoticeSeen`: function - Use this to permanently record that a user has seen a specific notice, warning, or announcement — pr
57
+ - `showSecurityNotice`: function - Use this to display a one-time security notice to users in the terminal — the message is shown only
58
+
59
+ ### loader
60
+
61
+ - `findConfigFile`: function - Use this to locate a Skrypt configuration file by searching a directory for any of the supported con
62
+ - `loadConfig`: function - Use this to load and parse a YAML/JSON configuration file for the autodocs tool, with optional path
63
+ - `validateConfig`: function - Use this to validate a configuration object before using it, catching all errors upfront rather than
64
+ - `checkApiKey`: function - Use this to verify whether a required API key environment variable is set for a given LLM provider b
65
+
66
+ ### generator
67
+
68
+ - `generateForElement`: function - Use this to generate documentation for a single API element (function, class, method, etc.) using an
69
+ - `generateForElements`: function - Use this to batch-generate documentation for multiple API elements in a single call, processing an a
70
+ - `formatAsMarkdown`: function - Use this to convert an array of generated documentation objects into a formatted Markdown string, re
71
+
72
+ ### organizer
73
+
74
+ - `organizeByTopic`: function - Use this to group a flat list of generated documentation objects into organized topic clusters — ide
75
+ - `detectCrossReferences`: function - Use this to automatically discover relationships between documented elements — finding which functio
76
+ - `getCrossRefsForElement`: function - Use this to filter a list of cross-references down to only those originating from a specific element
77
+ - `buildNavigation`: function - Use this to convert a flat list of documentation topics into a hierarchical navigation structure sui
78
+ - `generateSidebarConfig`: function - Use this to generate a sidebar navigation configuration from a list of documentation topics — compat
79
+ - `mergeTopicConfig`: function - Use this to safely merge a partial user-provided topic configuration with a set of defaults, ensurin
80
+
81
+ ### writer
82
+
83
+ - `writeLlmsTxt`: function - Use this to generate an `llms.txt` file for your project — a standardized index that helps LLMs (lik
84
+ - `writeDocsToDirectory`: function - Use this to persist generated documentation to disk, organizing output files in a directory structur
85
+ - `groupDocsByFile`: function - Use this to organize a flat list of generated documentation objects into groups by their source file
86
+ - `writeDocsByTopic`: function - Use this to write generated documentation files to disk, organized into topic-based subdirectories —
87
+
88
+ ### pr-comments
89
+
90
+ - `postPRComment`: function - Use this to automatically post documentation quality feedback as a review comment on a GitHub Pull R
91
+ - `postInlineComments`: function - Use this to post inline review comments on specific lines of a pull request, flagging documentation
92
+ - `analyzePRForDocs`: function - Use this to scan a pull request for documentation issues — missing docstrings, undocumented paramete
93
+
94
+ ### confluence
95
+
96
+ - `importConfluence`: function - Use this to convert a Confluence HTML space export into structured markdown pages, ready for use in
97
+
98
+ ### detect
99
+
100
+ - `detectFormat`: function - Use this to automatically identify which documentation framework a project uses, so you can process
101
+ - `isGitHubUrl`: function - Use this to validate whether a string is a GitHub repository or profile URL before processing it as
102
+ - `parseGitHubUrl`: function - Use this to extract the owner, repository name, branch/tag reference, and file path from a GitHub UR
103
+
104
+ ### docusaurus
105
+
106
+ - `importDocusaurus`: function - Use this to convert a Docusaurus documentation directory into a structured, normalized `ImportResult
107
+
108
+ ### gitbook
109
+
110
+ - `importGitBook`: function - Use this to convert a GitBook documentation directory into a structured import result, transforming
111
+
112
+ ### github
113
+
114
+ - `importFromGitHub`: function - Use this to pull documentation directly from a GitHub repository and import it into your system — no
115
+
116
+ ### markdown
117
+
118
+ - `importMarkdown`: function - Use this to convert a directory of Markdown or MDX files into a structured import result, where fold
119
+
120
+ ### mintlify
121
+
122
+ - `importMintlify`: function - Use this to convert a Mintlify documentation project into a standardized `ImportResult` format, read
123
+
124
+ ### notion
125
+
126
+ - `importNotion`: function - Use this to convert a Notion export folder into structured, importable page data — stripping UUIDs,
127
+
128
+ ### readme
129
+
130
+ - `importReadme`: function - Use this to convert a ReadMe.io documentation export into a structured import result, transforming R
131
+
132
+ ### transform
133
+
134
+ - `transformMintlifyCallouts`: function - Use this to convert Mintlify-flavored callout components (`<Note>`, `<Warning>`, `<Tip>`, `<Info>`,
135
+ - `transformDocusaurusAdmonitions`: function - Use this to convert Docusaurus admonition blocks (:::note, :::tip, :::danger, etc.) into a standardi
136
+ - `transformGitBookHints`: function - Use this to convert GitBook hint/callout blocks into `<Callout>` JSX components during documentation
137
+ - `transformReadmeCallouts`: function - Use this to convert ReadMe RDMD-style callout blocks (using emoji prefixes) into standard markdown o
138
+ - `transformNotionCallouts`: function - Use this to convert Notion-style callout markup — both `<aside>` HTML blocks and `:::callout` fenced
139
+ - `transformConfluenceCallouts`: function - Use this to convert Confluence structured macro callouts (`info`, `note`, `warning`, `tip`) into cle
140
+ - `transformMintlifyTabs`: function - Use this to convert Mintlify-flavored `<Tabs>/<Tab>` JSX syntax into standard Markdown or a compatib
141
+ - `transformDocusaurusTabs`: function - Use this to convert Docusaurus `<Tabs>` / `<TabItem>` JSX syntax into plain markdown or a renderable
142
+ - `transformGitBookTabs`: function - Use this to convert GitBook tab syntax into clean markdown, stripping the `{% tabs %}` / `{% tab %}`
143
+ - `transformReadmeCodeBlocks`: function - Use this to convert ReadMe.io's proprietary `[block:code]` syntax into standard `<CodeGroup>` compon
144
+ - `transformGitBookSteps`: function - Use this to convert GitBook stepper/step syntax into clean markdown, stripping the `{% stepper %}`,
145
+ - `transformGitBookExpandable`: function - Use this to convert GitBook expandable blocks into Accordion components for rendering in documentati
146
+ - `transformGitBookContentRef`: function - Use this to convert GitBook `content-ref` shortcode blocks into standard markdown links during docum
147
+ - `transformGitBookEmbed`: function - Use this to strip GitBook `{% embed url="..." %}` syntax from content, replacing it with plain URLs
148
+ - `transformNotionToggles`: function - Use this to convert Notion-exported toggle blocks (HTML `<details>`/`<summary>` elements) into `<Acc
149
+ - `transformConfluenceHtml`: function - Use this to convert Confluence HTML pages (including Atlassian Confluence macros) into clean, readab
150
+ - `stripDocusaurusImports`: function - Use this to clean Docusaurus-specific theme import statements from MDX/markdown content before proce
151
+ - `normalizeFrontmatter`: function - Use this to standardize frontmatter fields in markdown content to Skrypt format, optionally injectin
152
+ - `rewriteImagePaths`: function - Use this to update image paths in documentation content after assets have been copied to a new locat
153
+ - `stripNotionUUIDs`: function - Use this to clean up Notion export filenames by removing the 32-character hex UUID suffixes that Not
154
+ - `getSortWeight`: function - Use this to determine the sort order of a documentation file by extracting its position weight from
155
+
156
+ ### anthropic-client
157
+
158
+ - `AnthropicClient`: class - Use this to send prompts to Anthropic's Claude models and receive structured completions — with auto
159
+ - `constructor`: method - Use this to create an Anthropic-backed LLM client that handles retries and model configuration for s
160
+ - `isConfigured`: method - Use this to verify that an `AnthropicClient` instance is ready to make API calls before attempting c
161
+ - `complete`: method - Use this to send a conversation to Anthropic's Claude models and receive a completion response, hand
162
+
163
+ ### openai-client
164
+
165
+ - `OpenAICompatibleClient`: class - Use this to connect to any OpenAI-compatible LLM provider — including OpenAI, DeepSeek, Ollama, Open
166
+ - `constructor`: method - Use this to create an LLM client that connects to any OpenAI-compatible API provider (OpenAI, Azure,
167
+ - `isConfigured`: method - Use this to verify that an `OpenAICompatibleClient` instance is ready to make API calls before attem
168
+ - `complete`: method - Use this to send a chat completion request to any OpenAI-compatible API endpoint (OpenAI, Azure, Gro
169
+
170
+ ### content-type
171
+
172
+ - `classifyElement`: function - Use this to determine what type of documentation an API element needs — whether it's best suited for
173
+ - `classifyElements`: function - Use this to sort a mixed list of documentation elements into typed groups — API references, guides,
174
+ - `getRecommendedStructure`: function - Use this to automatically organize a mixed set of API elements into a recommended documentation stru
175
+ - `getPromptForContentType`: function - Use this to get the appropriate documentation generation prompt string for a given content type — so
176
+
177
+ ### go
178
+
179
+ - `GoScanner`: class - Use this to scan Go source files and extract API elements — functions, methods, structs, and interfa
180
+ - `canHandle`: method - Use this to check whether a Go source file should be processed by the `GoScanner` — it returns `true
181
+ - `scanFile`: method - Use this to extract API elements from a Go source file, returning all discovered functions, types, a
182
+
183
+ ### python
184
+
185
+ - `PythonScanner`: class - Use this to scan Python source files and extract structured metadata (functions, classes, imports, e
186
+ - `canHandle`: method - Use this to quickly check whether a file should be processed by the Python scanner before attempting
187
+ - `scanFile`: method - Use this to scan a Python source file and extract structured metadata — functions, classes, imports,
188
+
189
+ ### python_parser
190
+
191
+ - `get_docstring`: function - Use this to extract the docstring from any Python AST node (functions, classes, modules) when parsin
192
+ - `get_type_annotation`: function - Use this to convert a Python AST type annotation node into its human-readable string representation
193
+ - `get_default_value`: function - Use this to extract a human-readable string representation of a Python function parameter's default
194
+ - `extract_parameters`: function - Use this to convert Python AST function arguments into a structured list of parameter metadata — ide
195
+ - `build_signature`: function - Use this to reconstruct a human-readable function signature string from its parsed AST components —
196
+ - `extract_function`: function - Use this to extract structured metadata from a Python function or method AST node — including its na
197
+ - `extract_class`: function - Use this to parse a Python class AST node into a structured list of dictionaries containing the clas
198
+ - `scan_file`: function - Use this to extract all API elements from a Python source file — functions, classes, methods, import
199
+
200
+ ### rust
201
+
202
+ - `RustScanner`: class - Use this to scan Rust source files and extract public API elements — functions, structs, enums, impl
203
+ - `canHandle`: method - Use this to check whether a file path should be processed by the Rust scanner before attempting to s
204
+ - `scanFile`: method - Use this to extract API elements from a Rust source file, parsing its contents into a structured res
205
+
206
+ ### typescript
207
+
208
+ - `TypeScriptScanner`: class - Use this to scan TypeScript and JavaScript source files and extract API elements (functions, classes
209
+ - `canHandle`: method - Use this to quickly determine whether a file path is a TypeScript/JavaScript source file that the sc
210
+ - `scanFile`: method - Use this to extract API elements (functions, classes, methods, parameters) from a TypeScript or Java
211
+
212
+ ### files
213
+
214
+ - `findMdxFiles`: function - Use this to collect all Markdown and MDX file paths from a directory tree — useful for documentation
215
+ - `slugify`: function - Use this to convert any string into a clean, URL-safe slug — stripping special characters, spaces, a
216
+ - `parseFrontmatter`: function - Use this to extract structured metadata and body content from Markdown files that use YAML frontmatt
217
+
218
+ ### validation
219
+
220
+ - `validatePath`: function - Use this to safely resolve and validate file system paths before performing file operations — preven
221
+ - `validateUrl`: function - Use this to validate and sanitize URL strings before making HTTP requests or storing user-provided U
222
+ - `validateSlug`: function - Use this to validate that a string is a safe slug before using it in URLs, file paths, or database i
223
+ - `sanitizeForShell`: function - Use this to validate and sanitize strings before passing them to shell commands, git operations, or
224
+
225
+ ## API Details
226
+
227
+ ### getAuthConfig
228
+
229
+ **Type:** function
230
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
231
+
232
+ ```
233
+ function getAuthConfig(): AuthConfig
234
+ ```
235
+
236
+ Use this to synchronously retrieve the current authentication configuration from environment variables or a local auth file — without touching the keychain.
237
+
238
+ This is the fast, synchronous option for reading auth state. It checks `SKRYPT_API_KEY` env var first, then falls back to a local auth file. When you need keychain access (e.g., in interactive CLI flows), use `getAuthConfigAsync()` instead.
239
+
240
+ **Common use cases:**
241
+ - Reading auth config at startup in a script or server process
242
+ - Checking if a
243
+
244
+ **Example:**
245
+ ```typescript
246
+ // Inline types — no external imports needed
247
+ type AuthConfig = {
248
+ apiKey: string | undefined
249
+ email: string | undefined
250
+ }
251
+
252
+ // Simulate the auth file structure stored on disk
253
+ type AuthFileMeta = {
254
+ apiKey?: string
255
+ email?: string
256
+ }
257
+
258
+ // Simulate reading a local auth file (e.g., ~/.skrypt/auth.json
259
+ ```
260
+
261
+ ### getAuthConfigAsync
262
+
263
+ **Type:** function
264
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
265
+
266
+ ```
267
+ async function getAuthConfigAsync(): Promise<AuthConfig>
268
+ ```
269
+
270
+ Use this to retrieve the current user's authentication configuration in any CLI command action. It automatically resolves credentials by checking three sources in priority order: environment variable → system keychain → auth file on disk.
271
+
272
+ This is the **preferred method** for reading auth in all command handlers — it handles all credential sources transparently so you don't need to check each one manually.
273
+
274
+ ## Returns
275
+
276
+ | Condition | Result |
277
+ |---|---|
278
+ | `SKRYPT_API_KEY` env var is set | Returns
279
+
280
+ **Example:**
281
+ ```typescript
282
+ // Inline types — no external imports needed
283
+ type AuthConfig = {
284
+ apiKey: string
285
+ email?: string
286
+ }
287
+
288
+ type AuthFileMeta = {
289
+ email?: string
290
+ apiKey?: string
291
+ }
292
+
293
+ // --- Simulated dependencies (stand-ins for fs, keychain, etc.) ---
294
+
295
+ const mockAuthFile: AuthFileMeta = {
296
+ email: 'jane@example.com',
297
+
298
+ ```
299
+
300
+ ### saveAuthConfig
301
+
302
+ **Type:** function
303
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
304
+
305
+ ```
306
+ async function saveAuthConfig(config: AuthConfig): Promise<void>
307
+ ```
308
+
309
+ Use this to persist authentication configuration (API keys, endpoints, tokens) to a secure local config directory, with automatic keychain integration when available.
310
+
311
+ This function:
312
+ - Creates the config directory with restricted permissions (`0o700`) if it doesn't exist
313
+ - Attempts to store the API key in the system keychain for added security
314
+ - Falls back to writing credentials to a local config file if keychain storage is unavailable
315
+
316
+ ## Parameters
317
+
318
+ | Name | Type | Required | Description |
319
+ |--
320
+
321
+ **Example:**
322
+ ```typescript
323
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from 'fs'
324
+ import { join } from 'path'
325
+ import { homedir } from 'os'
326
+
327
+ // --- Inline types ---
328
+ interface AuthConfig {
329
+ apiKey?: string
330
+ endpoint?: string
331
+ token?: string
332
+ }
333
+
334
+ // --- Inline config path constants ---
335
+ const CONFIG_D
336
+ ```
337
+
338
+ ### clearAuth
339
+
340
+ **Type:** function
341
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
342
+
343
+ ```
344
+ async function clearAuth(): Promise<void>
345
+ ```
346
+
347
+ Use this to completely sign out a user by wiping all stored authentication credentials — both from the system keychain and any local auth config file.
348
+
349
+ This is the "logout" operation. It removes credentials from two places:
350
+ 1. **System keychain** (macOS Keychain, Linux Secret Service, Windows Credential Manager)
351
+ 2. **Local auth file** on disk (typically `~/.config/yourapp/auth.json` or similar)
352
+
353
+ After calling this, any subsequent authenticated requests will fail until the user logs in again.
354
+
355
+ ##
356
+
357
+ **Example:**
358
+ ```typescript
359
+ import { existsSync, unlinkSync, writeFileSync, mkdirSync } from 'fs'
360
+ import { join } from 'path'
361
+ import { homedir } from 'os'
362
+
363
+ // --- Inline simulation of keychain operations ---
364
+ const inMemoryKeychain: Record<string, string> = {
365
+ 'myapp/auth': 'super-secret-token-abc123'
366
+ }
367
+
368
+ async function keychai
369
+ ```
370
+
371
+ ### getKeyStorageMethod
372
+
373
+ **Type:** function
374
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
375
+
376
+ ```
377
+ async function getKeyStorageMethod(): Promise<'keychain' | 'file' | 'env' | 'none'>
378
+ ```
379
+
380
+ Use this to detect where an API key is currently stored, so you can display storage status to users, conditionally prompt for re-authentication, or branch logic based on the active credential source.
381
+
382
+ Returns a promise resolving to one of four string literals indicating the active storage method — checked in priority order: environment variable → keychain → file → none.
383
+
384
+ ### Return Values
385
+
386
+ | Value | Description |
387
+ |---|---|
388
+ | `'env'` | API key found in `SKRYPT_API_KEY` environment variable |
389
+ | `'
390
+
391
+ **Example:**
392
+ ```typescript
393
+ // Simulate the storage detection logic inline
394
+ // (mirrors the real priority order: env → keychain → file → none)
395
+
396
+ import { existsSync } from 'fs'
397
+ import { join } from 'path'
398
+ import { homedir } from 'os'
399
+
400
+ type KeyStorageMethod = 'keychain' | 'file' | 'env' | 'none'
401
+
402
+ // Simulate keychain lookup (real
403
+ ```
404
+
405
+ ### checkPlan
406
+
407
+ **Type:** function
408
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
409
+
410
+ ```
411
+ async function checkPlan(apiKey: string): Promise<PlanCheckResponse>
412
+ ```
413
+
414
+ Use this to verify an API key's validity and retrieve the associated subscription plan details before making API calls or gating features by plan tier.
415
+
416
+ ## Parameters
417
+
418
+ | Name | Type | Required | Description |
419
+ |------|------|----------|-------------|
420
+ | `apiKey` | `string` | Yes | The Bearer token used to authenticate against the plan endpoint |
421
+
422
+ ## Returns
423
+
424
+ Returns a `Promise<PlanCheckResponse>` that resolves with the plan details for the provided API key.
425
+
426
+ | Scenario | Result |
427
+ |----------|-----
428
+
429
+ **Example:**
430
+ ```typescript
431
+ // Inline types — no external imports needed
432
+ type PlanCheckResponse = {
433
+ plan: 'free' | 'pro' | 'enterprise'
434
+ valid: boolean
435
+ requestsPerMonth: number
436
+ expiresAt: string | null
437
+ error?: string
438
+ }
439
+
440
+ // Simulated implementation matching the real function's behavior
441
+ async function checkPlan(apiKey:
442
+ ```
443
+
444
+ ### requirePro
445
+
446
+ **Type:** function
447
+ **File:** /Users/debmukherjee/autodocs/src/auth/index.ts
448
+
449
+ ```
450
+ async function requirePro(commandName: string): Promise<boolean>
451
+ ```
452
+
453
+ Use this to gate CLI commands behind a Pro subscription, automatically printing upgrade instructions and returning `false` if the user isn't authenticated or doesn't have a Pro plan.
454
+
455
+ Call `requirePro` at the top of any command handler that requires a paid plan. It handles all messaging to the user — you just check the return value and exit early if it's `false`.
456
+
457
+ ## Parameters
458
+
459
+ | Name | Type | Required | Description |
460
+ |------|------|----------|-------------|
461
+ | `commandName` | `string` | ✅ | The
462
+
463
+ **Example:**
464
+ ```typescript
465
+ // Inline types — no external imports needed
466
+ type Plan = 'free' | 'pro' | 'enterprise'
467
+
468
+ interface AuthConfig {
469
+ apiKey: string | null
470
+ plan: Plan
471
+ email: string
472
+ }
473
+
474
+ // Simulate stored auth config (in real usage, read from disk/keychain)
475
+ const mockAuthStore: AuthConfig = {
476
+ apiKey: process.env.SKR
477
+ ```
478
+
479
+ ### keychainAvailable
480
+
481
+ **Type:** function
482
+ **File:** /Users/debmukherjee/autodocs/src/auth/keychain.ts
483
+
484
+ ```
485
+ async function keychainAvailable(): Promise<boolean>
486
+ ```
487
+
488
+ Use this to check whether the system keychain is available and functional before attempting to store or retrieve secrets. This prevents runtime errors in environments where keychain access is unavailable (e.g., headless CI servers, containers, or systems without a keyring daemon).
489
+
490
+ Returns `true` if the keychain is accessible and operational, `false` if the keyring module cannot be loaded or the keychain is non-functional.
491
+
492
+ ### Parameters
493
+
494
+ This function takes no parameters.
495
+
496
+ ### Returns
497
+
498
+ | Value
499
+
500
+ **Example:**
501
+ ```typescript
502
+ // Inline types and simulate the keychainAvailable behavior
503
+ // (self-contained — no external imports required)
504
+
505
+ // Simulated keyring entry for demonstration
506
+ class MockEntry {
507
+ constructor(private service: string, private account: string) {}
508
+ async getPassword(): Promise<string | null> {
509
+ // Sim
510
+ ```
511
+
512
+ ### keychainStore
513
+
514
+ **Type:** function
515
+ **File:** /Users/debmukherjee/autodocs/src/auth/keychain.ts
516
+
517
+ ```
518
+ async function keychainStore(key: string): Promise<boolean>
519
+ ```
520
+
521
+ Use this to securely store an API key or secret in the operating system's native keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service).
522
+
523
+ This is the recommended way to persist sensitive credentials locally without storing them in plaintext config files or environment variables.
524
+
525
+ ## Parameters
526
+
527
+ | Name | Type | Required | Description |
528
+ |------|------|----------|-------------|
529
+ | `key` | `string` | ✅ | The secret value (e.g. API key, token, password) to store in the system k
530
+
531
+ **Example:**
532
+ ```typescript
533
+ // Inline types to simulate keychainStore behavior
534
+ // (self-contained — no external imports required)
535
+
536
+ // Simulated in-memory keychain store for demonstration
537
+ const mockKeychain: Record<string, string> = {}
538
+
539
+ const SERVICE_NAME = 'my-app'
540
+ const ACCOUNT_NAME = 'default'
541
+
542
+ // Simulated keychainStore imp
543
+ ```
544
+
545
+ ### keychainRetrieve
546
+
547
+ **Type:** function
548
+ **File:** /Users/debmukherjee/autodocs/src/auth/keychain.ts
549
+
550
+ ```
551
+ async function keychainRetrieve(): Promise<string | null>
552
+ ```
553
+
554
+ Use this to securely retrieve a stored API key or password from the operating system's native keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service).
555
+
556
+ Returns `null` if the keyring is unavailable or no entry exists, making it safe to use as a fallback check before prompting the user for credentials.
557
+
558
+ ## Parameters
559
+
560
+ _None_ — retrieves from a fixed service/account name configured internally.
561
+
562
+ ## Returns
563
+
564
+ | Value | When |
565
+ |---|---|
566
+ | `Promise<string>` | A stored password/API
567
+
568
+ **Example:**
569
+ ```typescript
570
+ // Simulated keychain store (mimics OS keychain behavior)
571
+ const keychainStore: Record<string, string> = {}
572
+
573
+ // Inline types
574
+ type KeychainEntry = {
575
+ getPassword: () => string | null
576
+ }
577
+
578
+ type KeyringModule = {
579
+ Entry: new (service: string, account: string) => KeychainEntry
580
+ }
581
+
582
+ // Constants (as used in
583
+ ```
584
+
585
+ ### keychainDelete
586
+
587
+ **Type:** function
588
+ **File:** /Users/debmukherjee/autodocs/src/auth/keychain.ts
589
+
590
+ ```
591
+ async function keychainDelete(): Promise<boolean>
592
+ ```
593
+
594
+ Use this to securely delete a stored password/credential from the system keychain. This is useful for logout flows, credential rotation, or cleaning up stored secrets from the OS-level secure storage.
595
+
596
+ **Returns**
597
+ | Value | When |
598
+ |-------|------|
599
+ | `true` | The credential was found and successfully deleted from the keychain |
600
+ | `false` | The keyring module could not be loaded, or deletion failed |
601
+
602
+ > **Note:** This function targets a fixed service/account name pair internally (`SERVICE_NAME` /
603
+
604
+ **Example:**
605
+ ```typescript
606
+ // Simulated keychain store (mimics OS keychain behavior)
607
+ const keychainStore: Record<string, string> = {
608
+ "MyApp:default-user": "super-secret-token-abc123"
609
+ }
610
+
611
+ // Inline types
612
+ type KeychainEntry = {
613
+ service: string
614
+ account: string
615
+ deletePassword: () => void
616
+ }
617
+
618
+ // Simulate the keychain delete
619
+ ```
620
+
621
+ ### getKeychainPlatformName
622
+
623
+ **Type:** function
624
+ **File:** /Users/debmukherjee/autodocs/src/auth/keychain.ts
625
+
626
+ ```
627
+ function getKeychainPlatformName(): string
628
+ ```
629
+
630
+ Use this to display a human-readable name for the current platform's credential storage system in user-facing messages, logs, or CLI output.
631
+
632
+ Returns the appropriate keychain/credential manager name based on the operating system:
633
+
634
+ | Platform | Returns |
635
+ |----------|---------|
636
+ | macOS (`darwin`) | `"macOS Keychain"` |
637
+ | Windows (`win32`) | `"Windows Credential Manager"` |
638
+ | Linux / other | `"system keyring (libsecret)"` |
639
+
640
+ ### Parameters
641
+
642
+ None.
643
+
644
+ ### Returns
645
+
646
+ | Type | Description |
647
+ |------|-------
648
+
649
+ **Example:**
650
+ ```typescript
651
+ // Inline implementation of getKeychainPlatformName
652
+ function getKeychainPlatformName(): string {
653
+ switch (process.platform) {
654
+ case 'darwin': return 'macOS Keychain'
655
+ case 'win32': return 'Windows Credential Manager'
656
+ default: return 'system keyring (libsecret)'
657
+ }
658
+ }
659
+
660
+ // Example
661
+ ```
662
+
663
+ ### hasSeenNotice
664
+
665
+ **Type:** function
666
+ **File:** /Users/debmukherjee/autodocs/src/auth/notices.ts
667
+
668
+ ```
669
+ function hasSeenNotice(id: string): boolean
670
+ ```
671
+
672
+ Use this to check whether a user has already acknowledged a specific notice, warning, or announcement — preventing repeat displays of one-time messages.
673
+
674
+ This is ideal for CLI tools or apps that show onboarding tips, deprecation warnings, or changelog notices only once per user.
675
+
676
+ ## Parameters
677
+
678
+ | Name | Type | Required | Description |
679
+ |------|------|----------|-------------|
680
+ | `id` | `string` | ✅ | Unique identifier for the notice to check (e.g. `"welcome-v2"`, `"deprecation-warning"`) |
681
+
682
+ ## Ret
683
+
684
+ **Example:**
685
+ ```typescript
686
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs'
687
+ import { join } from 'path'
688
+ import { homedir } from 'os'
689
+
690
+ // --- Inline implementation (self-contained, no external imports) ---
691
+
692
+ const CONFIG_DIR = join(homedir(), '.config', 'myapp')
693
+ const NOTICES_FILE = join(CONFIG_DIR, 'noti
694
+ ```
695
+
696
+ ### markNoticeSeen
697
+
698
+ **Type:** function
699
+ **File:** /Users/debmukherjee/autodocs/src/auth/notices.ts
700
+
701
+ ```
702
+ function markNoticeSeen(id: string): void
703
+ ```
704
+
705
+ Use this to permanently record that a user has seen a specific notice, warning, or announcement — preventing it from being shown again in future sessions.
706
+
707
+ The notice state is persisted to disk, so once marked as seen, the record survives process restarts. Each notice is stored with the exact timestamp it was acknowledged.
708
+
709
+ ### Parameters
710
+
711
+ | Name | Type | Required | Description |
712
+ |------|------|----------|-------------|
713
+ | `id` | `string` | ✅ | Unique identifier for the notice (e.g. `"welcome-v2"
714
+
715
+ **Example:**
716
+ ```typescript
717
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs'
718
+ import { join } from 'path'
719
+ import { homedir } from 'os'
720
+
721
+ // --- Inline implementation (do not import from autodocs) ---
722
+
723
+ const NOTICES_DIR = join(homedir(), '.autodocs')
724
+ const NOTICES_FILE = join(NOTICES_DIR, 'notices.json')
725
+
726
+ t
727
+ ```
728
+
729
+ ### showSecurityNotice
730
+
731
+ **Type:** function
732
+ **File:** /Users/debmukherjee/autodocs/src/auth/notices.ts
733
+
734
+ ```
735
+ function showSecurityNotice(): void
736
+ ```
737
+
738
+ Use this to display a one-time security notice to users in the terminal — the message is shown only once per machine and silently skipped on all subsequent runs.
739
+
740
+ This is ideal for CLI tools that need to surface important security information (e.g., API key handling, data privacy warnings) without repeatedly interrupting the user's workflow.
741
+
742
+ ### Parameters
743
+
744
+ This function takes no parameters.
745
+
746
+ ### Returns
747
+
748
+ | Condition | Result |
749
+ |---|---|
750
+ | First time called on this machine | Prints a formatted
751
+
752
+ **Example:**
753
+ ```typescript
754
+ import * as fs from 'fs'
755
+ import * as path from 'path'
756
+ import * as os from 'os'
757
+
758
+ // --- Inline implementation (mirrors autodocs internals) ---
759
+
760
+ const NOTICES_DIR = path.join(os.homedir(), '.autodocs')
761
+ const NOTICES_FILE = path.join(NOTICES_DIR, 'notices.json')
762
+
763
+ type NoticesState = {
764
+ seen: Record<st
765
+ ```
766
+
767
+ ### autoFixExample
768
+
769
+ **Type:** function
770
+ **File:** /Users/debmukherjee/autodocs/src/autofix/index.ts
771
+
772
+ ```
773
+ async function autoFixExample(example: CodeExample, client: LLMClient, options: AutoFixOptions = {}): Promise<FixResult>
774
+ ```
775
+
776
+ Use this to automatically repair broken or invalid code examples by iteratively applying LLM-powered fixes until the code compiles and runs correctly.
777
+
778
+ This function takes a code example that may contain errors, submits it to an LLM client for analysis and correction, and retries up to a configurable number of times — returning the fixed code along with metadata about what changed and how many attempts it took.
779
+
780
+ ## Parameters
781
+
782
+ | Name | Type | Required | Description |
783
+ |------|------|----------|--
784
+
785
+ **Example:**
786
+ ```typescript
787
+ // ---- Inline type definitions (no external imports needed) ----
788
+
789
+ type CodeExample = {
790
+ code: string
791
+ language: string
792
+ errorMessage?: string
793
+ }
794
+
795
+ type AutoFixOptions = {
796
+ maxIterations?: number
797
+ verbose?: boolean
798
+ }
799
+
800
+ type FixResult = {
801
+ success: boolean
802
+ fixedCode: string | null
803
+ iterations:
804
+ ```
805
+
806
+ ### autoFixBatch
807
+
808
+ **Type:** function
809
+ **File:** /Users/debmukherjee/autodocs/src/autofix/index.ts
810
+
811
+ ```
812
+ async function autoFixBatch(examples: CodeExample[], client: LLMClient, options: AutoFixOptions = {}): Promise<Map<number, FixResult>>
813
+ ```
814
+
815
+ Use this to automatically fix multiple broken code examples in a single batch operation, getting back a map of results indexed by position.
816
+
817
+ This is the batch version of `autoFix` — ideal when you have a collection of code snippets that need validation and repair, such as processing documentation examples, test fixtures, or user-submitted code samples all at once.
818
+
819
+ ## Parameters
820
+
821
+ | Name | Type | Required | Description |
822
+ |------|------|----------|-------------|
823
+ | `examples` | `CodeExample[]` | ✅
824
+
825
+ **Example:**
826
+ ```typescript
827
+ // ─── Inline types (do NOT import from autodocs) ───────────────────────────────
828
+
829
+ type CodeExample = {
830
+ code: string
831
+ language?: string
832
+ filename?: string
833
+ }
834
+
835
+ type FixResult = {
836
+ success: boolean
837
+ fixedCode?: string
838
+ error?: string
839
+ attempts?: number
840
+ }
841
+
842
+ type AutoFixOptions = {
843
+ maxAttempts?:
844
+ ```
845
+
846
+ ### createTypeScriptValidator
847
+
848
+ **Type:** function
849
+ **File:** /Users/debmukherjee/autodocs/src/autofix/index.ts
850
+
851
+ ```
852
+ function createTypeScriptValidator(): (code: string) => Promise<ValidationResult>
853
+ ```
854
+
855
+ Use this to validate TypeScript code strings at runtime — perfect for checking LLM-generated code, user-submitted snippets, or dynamically built TypeScript before execution.
856
+
857
+ Returns a validator function you call with any TypeScript code string. The validator uses the TypeScript compiler (`tsc`) under the hood to catch type errors, syntax issues, and compilation failures.
858
+
859
+ ## Parameters
860
+
861
+ This factory function takes no parameters.
862
+
863
+ ## Returns
864
+
865
+ | Value | Type | Description |
866
+ |---|---|---|
867
+ | `valid
868
+
869
+ **Example:**
870
+ ```typescript
871
+ import { transpileModule, type TranspileOptions } from 'typescript'
872
+
873
+ // --- Inline types (mirrors the real ValidationResult) ---
874
+ interface ValidationResult {
875
+ valid: boolean
876
+ errors: string[]
877
+ }
878
+
879
+ // --- Self-contained implementation mirroring the real function ---
880
+ function createTypeScriptValidator
881
+ ```
882
+
883
+ ### createPythonValidator
884
+
885
+ **Type:** function
886
+ **File:** /Users/debmukherjee/autodocs/src/autofix/index.ts
887
+
888
+ ```
889
+ function createPythonValidator(): (code: string) => Promise<ValidationResult>
890
+ ```
891
+
892
+ Use this to validate Python code syntax before executing or storing it — catches syntax errors without running the code.
893
+
894
+ `createPythonValidator` returns a reusable validator function that writes code to a temporary file and checks it with `python3 -m py_compile`. Requires `python3` to be available in your system `PATH`.
895
+
896
+ ## Parameters
897
+
898
+ The factory function takes no parameters. The returned validator accepts:
899
+
900
+ | Name | Type | Required | Description |
901
+ |------|------|----------|-------------|
902
+ | `c
903
+
904
+ **Example:**
905
+ ```typescript
906
+ import { spawnSync } from 'child_process'
907
+ import { writeFileSync, unlinkSync } from 'fs'
908
+ import { join } from 'path'
909
+ import { tmpdir } from 'os'
910
+
911
+ // Inline the ValidationResult type
912
+ type ValidationError = {
913
+ message: string
914
+ line?: number
915
+ }
916
+
917
+ type ValidationResult = {
918
+ valid: boolean
919
+ errors: Val
920
+ ```
921
+
922
+ ### findConfigFile
923
+
924
+ **Type:** function
925
+ **File:** /Users/debmukherjee/autodocs/src/config/loader.ts
926
+
927
+ ```
928
+ function findConfigFile(dir: string): string | null
929
+ ```
930
+
931
+ Use this to locate a Skrypt configuration file by searching a directory for any of the supported config filenames (`.skrypt.yaml`, `.skrypt.yml`, `skrypt.yaml`, `skrypt.yml`).
932
+
933
+ This is useful when you need to resolve the config file path before loading it — for example, when bootstrapping a CLI tool or build process that needs to find project-level configuration starting from a given directory.
934
+
935
+ ### Parameters
936
+
937
+ | Name | Type | Required | Description |
938
+ |------|------|----------|-------------|
939
+ | `
940
+
941
+ **Example:**
942
+ ```typescript
943
+ import { existsSync } from 'fs'
944
+ import { join } from 'path'
945
+
946
+ // Inline the supported config filenames (mirrors the real implementation)
947
+ const CONFIG_FILENAMES = ['.skrypt.yaml', '.skrypt.yml', 'skrypt.yaml', 'skrypt.yml']
948
+
949
+ // Self-contained implementation of findConfigFile
950
+ function findConfigFile(di
951
+ ```
952
+
953
+ ### loadConfig
954
+
955
+ **Type:** function
956
+ **File:** /Users/debmukherjee/autodocs/src/config/loader.ts
957
+
958
+ ```
959
+ function loadConfig(configPath?: string): Config
960
+ ```
961
+
962
+ Use this to load and parse a YAML/JSON configuration file for the autodocs tool, with optional path override. When no path is provided, it searches for a config file in default locations (e.g., `autodocs.config.yml` in the current directory). When a path is provided, it loads that specific file — throwing immediately if it doesn't exist.
963
+
964
+ **Parameters**
965
+
966
+ | Name | Type | Required | Description |
967
+ |------|------|----------|-------------|
968
+ | `configPath` | `string` | No | Explicit path to a config fi
969
+
970
+ **Example:**
971
+ ```typescript
972
+ import { existsSync, readFileSync } from 'fs'
973
+ import { join } from 'path'
974
+
975
+ // ── Inline types (mirrors autodocs internals) ────────────────────────────────
976
+ type LLMProvider = 'openai' | 'anthropic' | 'gemini'
977
+
978
+ interface Config {
979
+ provider: LLMProvider
980
+ model: string
981
+ outputDir: string
982
+ include:
983
+ ```
984
+
985
+ ### validateConfig
986
+
987
+ **Type:** function
988
+ **File:** /Users/debmukherjee/autodocs/src/config/loader.ts
989
+
990
+ ```
991
+ function validateConfig(config: Config): string[]
992
+ ```
993
+
994
+ Use this to validate a configuration object before using it, catching all errors upfront rather than failing at runtime.
995
+
996
+ `validateConfig` checks a `Config` object against known rules (such as supported version numbers) and returns a list of human-readable error messages. An empty array means the config is valid.
997
+
998
+ ## Parameters
999
+
1000
+ | Name | Type | Required | Description |
1001
+ |------|------|----------|-------------|
1002
+ | `config` | `Config` | Yes | The configuration object to validate. Must include at min
1003
+
1004
+ **Example:**
1005
+ ```typescript
1006
+ // Inline type definition (mirrors the real Config shape)
1007
+ type LLMProvider = 'openai' | 'anthropic' | 'ollama'
1008
+
1009
+ type Config = {
1010
+ version: number
1011
+ provider?: LLMProvider
1012
+ model?: string
1013
+ license?: string
1014
+ [key: string]: unknown
1015
+ }
1016
+
1017
+ // Inline implementation matching the real validateConfig logic
1018
+ f
1019
+ ```
1020
+
1021
+ ### checkApiKey
1022
+
1023
+ **Type:** function
1024
+ **File:** /Users/debmukherjee/autodocs/src/config/loader.ts
1025
+
1026
+ ```
1027
+ function checkApiKey(provider: LLMProvider): { ok: boolean; envKey: string | null }
1028
+ ```
1029
+
1030
+ Use this to verify whether a required API key environment variable is set for a given LLM provider before making requests.
1031
+
1032
+ Returns `{ ok: true }` for providers that don't require an API key (e.g., Ollama), and checks the appropriate environment variable for cloud providers (e.g., OpenAI, Anthropic). This is useful for fail-fast validation at startup or before executing LLM calls.
1033
+
1034
+ ### Parameters
1035
+
1036
+ | Name | Type | Required | Description |
1037
+ |------|------|----------|-------------|
1038
+ | `provider` | `L
1039
+
1040
+ **Example:**
1041
+ ```typescript
1042
+ // Inline the types and dependencies — no external imports needed
1043
+ type LLMProvider = 'openai' | 'anthropic' | 'ollama' | 'gemini'
1044
+
1045
+ const PROVIDER_ENV_KEYS: Record<LLMProvider, string | null> = {
1046
+ openai: 'OPENAI_API_KEY',
1047
+ anthropic: 'ANTHROPIC_API_KEY',
1048
+ ollama: null, // No API key required
1049
+ ge
1050
+ ```
1051
+
1052
+ ### generateForElement
1053
+
1054
+ **Type:** function
1055
+ **File:** /Users/debmukherjee/autodocs/src/generator/generator.ts
1056
+
1057
+ ```
1058
+ async function generateForElement(element: APIElement, client: LLMClient, options: GenerationOptions, onProgress?: (progress: GenerationProgress) => void): Promise<GeneratedDoc>
1059
+ ```
1060
+
1061
+ Use this to generate documentation for a single API element (function, class, method, etc.) using an LLM client, with optional real-time progress tracking.
1062
+
1063
+ This is the core documentation generation function — pass it a parsed API element and an LLM client, and it returns structured documentation ready for output. Use `onProgress` to stream status updates to a UI or CLI spinner.
1064
+
1065
+ ## Parameters
1066
+
1067
+ | Name | Type | Required | Description |
1068
+ |------|------|----------|-------------|
1069
+ | `element` | `APIEl
1070
+
1071
+ **Example:**
1072
+ ```typescript
1073
+ // ─── Inline type definitions (no external imports needed) ───────────────────
1074
+
1075
+ type APIElement = {
1076
+ name: string
1077
+ kind: 'function' | 'class' | 'method' | 'interface' | 'type'
1078
+ signature: string
1079
+ docstring?: string
1080
+ filePath: string
1081
+ lineNumber: number
1082
+ }
1083
+
1084
+ type LLMClient = {
1085
+ model: string
1086
+
1087
+ ```
1088
+
1089
+ ### generateForElements
1090
+
1091
+ **Type:** function
1092
+ **File:** /Users/debmukherjee/autodocs/src/generator/generator.ts
1093
+
1094
+ ```
1095
+ async function generateForElements(elements: APIElement[], client: LLMClient, options: GenerationOptions): Promise<GeneratedDoc[]>
1096
+ ```
1097
+
1098
+ Use this to batch-generate documentation for multiple API elements in a single call, processing an array of functions, classes, or methods through an LLM client with shared generation options.
1099
+
1100
+ This is the primary entry point for bulk documentation generation — pass in your scanned API elements, an LLM client, and configuration options to receive an array of generated docs ready for output.
1101
+
1102
+ ## Parameters
1103
+
1104
+ | Name | Type | Required | Description |
1105
+ |------|------|----------|-------------|
1106
+ | `eleme
1107
+
1108
+ **Example:**
1109
+ ```typescript
1110
+ // ─── Inline type definitions (no external imports needed) ───────────────────
1111
+
1112
+ type APIElement = {
1113
+ name: string
1114
+ kind: 'function' | 'class' | 'method' | 'interface'
1115
+ signature: string
1116
+ docstring?: string
1117
+ sourceContext?: string
1118
+ filePath: string
1119
+ }
1120
+
1121
+ type GeneratedDoc = {
1122
+ elementName: strin
1123
+ ```
1124
+
1125
+ ### formatAsMarkdown
1126
+
1127
+ **Type:** function
1128
+ **File:** /Users/debmukherjee/autodocs/src/generator/generator.ts
1129
+
1130
+ ```
1131
+ function formatAsMarkdown(docs: GeneratedDoc[], title: string): string
1132
+ ```
1133
+
1134
+ Use this to convert an array of generated documentation objects into a formatted Markdown string, ready to write to a `.md` file or display in a docs portal.
1135
+
1136
+ Takes structured doc data (functions, classes, methods) and a page title, and returns a complete Markdown document with sections organized by element type.
1137
+
1138
+ ## Parameters
1139
+
1140
+ | Name | Type | Required | Description |
1141
+ |------|------|----------|-------------|
1142
+ | `docs` | `GeneratedDoc[]` | ✅ | Array of generated documentation objects, each contai
1143
+
1144
+ **Example:**
1145
+ ```typescript
1146
+ // --- Inline types (mirrors autodocs internals) ---
1147
+ type ElementKind = 'function' | 'class' | 'method'
1148
+
1149
+ interface APIElement {
1150
+ name: string
1151
+ kind: ElementKind
1152
+ signature?: string
1153
+ }
1154
+
1155
+ interface GeneratedDoc {
1156
+ element: APIElement
1157
+ documentation: string
1158
+ }
1159
+
1160
+ // --- Inline implementation of formatA
1161
+ ```
1162
+
1163
+ ### organizeByTopic
1164
+
1165
+ **Type:** function
1166
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1167
+
1168
+ ```
1169
+ function organizeByTopic(docs: GeneratedDoc[], config: TopicConfig = DEFAULT_TOPIC_CONFIG): Topic[]
1170
+ ```
1171
+
1172
+ Use this to group a flat list of generated documentation objects into organized topic clusters — ideal for building navigation menus, documentation sites, or categorized API references.
1173
+
1174
+ ## Parameters
1175
+
1176
+ | Name | Type | Required | Description |
1177
+ |------|------|----------|-------------|
1178
+ | `docs` | `GeneratedDoc[]` | Yes | Array of generated documentation objects to organize. Each doc must include at least a `topic` or category field used for grouping. |
1179
+ | `config` | `TopicConfig` | No | Configuratio
1180
+
1181
+ **Example:**
1182
+ ```typescript
1183
+ // ── Inline types (do NOT import from autodocs) ──────────────────────────────
1184
+
1185
+ type GeneratedDoc = {
1186
+ id: string
1187
+ title: string
1188
+ topic: string // primary grouping key
1189
+ content: string
1190
+ slug: string
1191
+ }
1192
+
1193
+ type Topic = {
1194
+ name: string
1195
+ slug: string
1196
+ docs: GeneratedDoc[]
1197
+ }
1198
+
1199
+ type TopicCo
1200
+ ```
1201
+
1202
+ ### detectCrossReferences
1203
+
1204
+ **Type:** function
1205
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1206
+
1207
+ ```
1208
+ function detectCrossReferences(docs: GeneratedDoc[]): CrossReference[]
1209
+ ```
1210
+
1211
+ Use this to automatically discover relationships between documented elements — finding which functions, classes, or types reference each other by name across your documentation set.
1212
+
1213
+ Given a list of generated documentation objects, it scans each element's content and metadata to detect when one element mentions another by name, returning a list of cross-reference links you can use to build navigation, "See Also" sections, or dependency graphs.
1214
+
1215
+ ## Parameters
1216
+
1217
+ | Name | Type | Required | Descripti
1218
+
1219
+ **Example:**
1220
+ ```typescript
1221
+ // ─── Inline types (do not import from autodocs) ───────────────────────────────
1222
+
1223
+ type ElementKind = 'function' | 'class' | 'interface' | 'type'
1224
+
1225
+ interface DocElement {
1226
+ name: string
1227
+ kind: ElementKind
1228
+ description: string
1229
+ params?: { name: string; type: string }[]
1230
+ returns?: string
1231
+ }
1232
+
1233
+ interfa
1234
+ ```
1235
+
1236
+ ### getCrossRefsForElement
1237
+
1238
+ **Type:** function
1239
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1240
+
1241
+ ```
1242
+ function getCrossRefsForElement(elementName: string, allRefs: CrossReference[]): CrossReference[]
1243
+ ```
1244
+
1245
+ Use this to filter a list of cross-references down to only those originating from a specific element — useful when building documentation graphs, dependency trees, or navigation links for a given function, class, or module.
1246
+
1247
+ ## Parameters
1248
+
1249
+ | Name | Type | Required | Description |
1250
+ |------|------|----------|-------------|
1251
+ | `elementName` | `string` | ✅ | The name of the element to find cross-references for (matched against `fromElement`) |
1252
+ | `allRefs` | `CrossReference[]` | ✅ | The full list of cr
1253
+
1254
+ **Example:**
1255
+ ```typescript
1256
+ // Inline the CrossReference type (no external imports needed)
1257
+ type CrossReference = {
1258
+ fromElement: string
1259
+ toElement: string
1260
+ type?: string
1261
+ description?: string
1262
+ }
1263
+
1264
+ // Inline the function implementation
1265
+ function getCrossRefsForElement(
1266
+ elementName: string,
1267
+ allRefs: CrossReference[]
1268
+ ): Cros
1269
+ ```
1270
+
1271
+ ### buildNavigation
1272
+
1273
+ **Type:** function
1274
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1275
+
1276
+ ```
1277
+ function buildNavigation(topics: Topic[]): NavigationItem[]
1278
+ ```
1279
+
1280
+ Use this to convert a flat list of documentation topics into a hierarchical navigation structure suitable for rendering sidebars, menus, or breadcrumbs.
1281
+
1282
+ Each topic becomes a top-level navigation item with its documented elements nested as children, with auto-generated URL paths.
1283
+
1284
+ ## Parameters
1285
+
1286
+ | Name | Type | Required | Description |
1287
+ |------|------|----------|-------------|
1288
+ | `topics` | `Topic[]` | ✅ | Array of topics, each containing a name, id, and list of associated docs |
1289
+
1290
+ ## Returns
1291
+
1292
+ Retu
1293
+
1294
+ **Example:**
1295
+ ```typescript
1296
+ // --- Inline types (mirrors the real library's shape) ---
1297
+ type DocElement = {
1298
+ name: string;
1299
+ description?: string;
1300
+ };
1301
+
1302
+ type Doc = {
1303
+ element: DocElement;
1304
+ };
1305
+
1306
+ type Topic = {
1307
+ id: string;
1308
+ name: string;
1309
+ docs: Doc[];
1310
+ };
1311
+
1312
+ type NavigationItem = {
1313
+ title: string;
1314
+ path: string;
1315
+ children?: Nav
1316
+ ```
1317
+
1318
+ ### generateSidebarConfig
1319
+
1320
+ **Type:** function
1321
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1322
+
1323
+ ```
1324
+ function generateSidebarConfig(topics: Topic[]): object
1325
+ ```
1326
+
1327
+ Use this to generate a sidebar navigation configuration from a list of documentation topics — compatible with multiple documentation platforms (Mintlify, Docusaurus, etc.).
1328
+
1329
+ Given an array of topics (each with an ID, name, and list of docs), this function produces a structured `navigation` object where each topic becomes a group with slugified page paths.
1330
+
1331
+ ### Parameters
1332
+
1333
+ | Name | Type | Required | Description |
1334
+ |------|------|----------|-------------|
1335
+ | `topics` | `Topic[]` | ✅ | Array of topic
1336
+
1337
+ **Example:**
1338
+ ```typescript
1339
+ // ── Inline types (no external imports needed) ──────────────────────────────
1340
+ type DocElement = { name: string }
1341
+ type GeneratedDoc = { element: DocElement }
1342
+ type Topic = {
1343
+ id: string
1344
+ name: string
1345
+ docs: GeneratedDoc[]
1346
+ }
1347
+
1348
+ // ── Inline slugify utility ────────────────────────────────────────────
1349
+ ```
1350
+
1351
+ ### mergeTopicConfig
1352
+
1353
+ **Type:** function
1354
+ **File:** /Users/debmukherjee/autodocs/src/generator/organizer.ts
1355
+
1356
+ ```
1357
+ function mergeTopicConfig(userConfig: Partial<TopicConfig>, defaults: TopicConfig = DEFAULT_TOPIC_CONFIG): TopicConfig
1358
+ ```
1359
+
1360
+ Use this to safely merge a partial user-provided topic configuration with a set of defaults, ensuring all required fields are always present in the final config.
1361
+
1362
+ This is useful when users supply only a subset of configuration options (e.g., overriding a few topics) and you need a complete, valid `TopicConfig` to work with — without manually checking for missing fields.
1363
+
1364
+ ### Parameters
1365
+
1366
+ | Name | Type | Required | Description |
1367
+ |------|------|----------|-------------|
1368
+ | `userConfig` | `Partial<To
1369
+
1370
+ **Example:**
1371
+ ```typescript
1372
+ // Inline types (do not import from autodocs)
1373
+ type Topic = {
1374
+ label: string
1375
+ description?: string
1376
+ order?: number
1377
+ }
1378
+
1379
+ type TopicConfig = {
1380
+ topics: Record<string, Topic>
1381
+ }
1382
+
1383
+ // Simulated DEFAULT_TOPIC_CONFIG
1384
+ const DEFAULT_TOPIC_CONFIG: TopicConfig = {
1385
+ topics: {
1386
+ guides: { label: 'Guides', des
1387
+ ```
1388
+
1389
+ ### writeLlmsTxt
1390
+
1391
+ **Type:** function
1392
+ **File:** /Users/debmukherjee/autodocs/src/generator/writer.ts
1393
+
1394
+ ```
1395
+ async function writeLlmsTxt(docs: GeneratedDoc[], outputDir: string, options: { projectName?: string; description?: string } = {}): Promise<void>
1396
+ ```
1397
+
1398
+ Use this to generate an `llms.txt` file for your project — a standardized index that helps LLMs (like ChatGPT, Claude, etc.) discover and understand your API documentation. Follows the [llmstxt.org](https://llmstxt.org) convention for Answer Engine Optimization (AEO).
1399
+
1400
+ ## Parameters
1401
+
1402
+ | Name | Type | Required | Description |
1403
+ |------|------|----------|-------------|
1404
+ | `docs` | `GeneratedDoc[]` | ✅ Yes | Array of generated documentation objects to index |
1405
+ | `outputDir` | `string` | ✅ Yes | Director
1406
+
1407
+ **Example:**
1408
+ ```typescript
1409
+ import { mkdir, writeFile } from 'fs/promises'
1410
+ import { join } from 'path'
1411
+ import { tmpdir } from 'os'
1412
+
1413
+ // --- Inline types (mirrors the real GeneratedDoc shape) ---
1414
+ type GeneratedDoc = {
1415
+ title: string
1416
+ description?: string
1417
+ outputPath: string
1418
+ content: string
1419
+ slug?: string
1420
+ }
1421
+
1422
+ // --- Inline i
1423
+ ```
1424
+
1425
+ ### writeDocsToDirectory
1426
+
1427
+ **Type:** function
1428
+ **File:** /Users/debmukherjee/autodocs/src/generator/writer.ts
1429
+
1430
+ ```
1431
+ async function writeDocsToDirectory(results: FileGenerationResult[], outputDir: string, sourceDir: string): Promise<{ filesWritten: number; totalDocs: number }>
1432
+ ```
1433
+
1434
+ Use this to persist generated documentation to disk, organizing output files in a directory structure that mirrors your source code layout.
1435
+
1436
+ After generating docs for your codebase, `writeDocsToDirectory` takes the in-memory results and writes each file's documentation to the corresponding path under `outputDir`, preserving the relative structure from `sourceDir`. It returns a summary of how many files were written and how many total doc entries were produced.
1437
+
1438
+ ### Parameters
1439
+
1440
+ | Name | Type | Re
1441
+
1442
+ **Example:**
1443
+ ```typescript
1444
+ import { mkdir, writeFile } from 'fs/promises'
1445
+ import { dirname, join, relative, resolve, basename } from 'path'
1446
+ import { existsSync } from 'fs'
1447
+
1448
+ // ── Inline types (mirrors autodocs internals) ────────────────────────────────
1449
+
1450
+ interface GeneratedDoc {
1451
+ name: string
1452
+ kind: 'function' | 'class' | '
1453
+ ```
1454
+
1455
+ ### groupDocsByFile
1456
+
1457
+ **Type:** function
1458
+ **File:** /Users/debmukherjee/autodocs/src/generator/writer.ts
1459
+
1460
+ ```
1461
+ function groupDocsByFile(docs: GeneratedDoc[]): FileGenerationResult[]
1462
+ ```
1463
+
1464
+ Use this to organize a flat list of generated documentation objects into groups by their source file, making it easy to write one output file per source file.
1465
+
1466
+ This is the key step between generating individual doc entries and writing them to disk — it collapses a flat array into a structure where each entry represents a single source file and all the docs that belong to it.
1467
+
1468
+ ### Parameters
1469
+
1470
+ | Name | Type | Required | Description |
1471
+ |------|------|----------|-------------|
1472
+ | `docs` | `GeneratedDo
1473
+
1474
+ **Example:**
1475
+ ```typescript
1476
+ // ─── Inline types (do not import from autodocs) ───────────────────────────────
1477
+
1478
+ interface CodeElement {
1479
+ name: string
1480
+ filePath: string
1481
+ kind: 'function' | 'class' | 'interface' | 'type'
1482
+ signature: string
1483
+ }
1484
+
1485
+ interface GeneratedDoc {
1486
+ element: CodeElement
1487
+ markdown: string
1488
+ generatedAt: Da
1489
+ ```
1490
+
1491
+ ### writeDocsByTopic
1492
+
1493
+ **Type:** function
1494
+ **File:** /Users/debmukherjee/autodocs/src/generator/writer.ts
1495
+
1496
+ ```
1497
+ async function writeDocsByTopic(docs: GeneratedDoc[], outputDir: string): Promise<{ filesWritten: number; totalDocs: number; topics: Topic[] }>
1498
+ ```
1499
+
1500
+ Use this to write generated documentation files to disk, organized into topic-based subdirectories — ideal for creating structured doc sites where related functions and classes are grouped together.
1501
+
1502
+ ## Parameters
1503
+
1504
+ | Name | Type | Required | Description |
1505
+ |------|------|----------|-------------|
1506
+ | `docs` | `GeneratedDoc[]` | ✅ | Array of generated documentation objects, each containing content and metadata about a code element |
1507
+ | `outputDir` | `string` | ✅ | Root directory path where topic-orga
1508
+
1509
+ **Example:**
1510
+ ```typescript
1511
+ import { mkdir, writeFile } from 'fs/promises'
1512
+ import { join } from 'path'
1513
+
1514
+ // --- Inline types (mirrors autodocs internals) ---
1515
+ type GeneratedDoc = {
1516
+ elementName: string
1517
+ topic: string
1518
+ content: string
1519
+ filePath: string
1520
+ }
1521
+
1522
+ type Topic = {
1523
+ name: string
1524
+ slug: string
1525
+ docCount: number
1526
+ }
1527
+
1528
+ // -
1529
+ ```
1530
+
1531
+ ### postPRComment
1532
+
1533
+ **Type:** function
1534
+ **File:** /Users/debmukherjee/autodocs/src/github/pr-comments.ts
1535
+
1536
+ ```
1537
+ async function postPRComment(config: PRCommentConfig, issues: DocumentationIssue[]): Promise<CommentResult>
1538
+ ```
1539
+
1540
+ Use this to automatically post documentation quality feedback as a review comment on a GitHub Pull Request, summarizing all detected documentation issues in one structured comment.
1541
+
1542
+ ## Parameters
1543
+
1544
+ | Name | Type | Required | Description |
1545
+ |------|------|----------|-------------|
1546
+ | `config` | `PRCommentConfig` | Yes | GitHub PR connection details including repo owner, repo name, PR number, and optional auth token |
1547
+ | `issues` | `DocumentationIssue[]` | Yes | Array of documentation issues to report
1548
+
1549
+ **Example:**
1550
+ ```typescript
1551
+ // --- Inline types (do not import from autodocs) ---
1552
+ type PRCommentConfig = {
1553
+ owner: string;
1554
+ repo: string;
1555
+ prNumber: number;
1556
+ token?: string;
1557
+ };
1558
+
1559
+ type DocumentationIssue = {
1560
+ file: string;
1561
+ line: number;
1562
+ severity: 'error' | 'warning' | 'info';
1563
+ message: string;
1564
+ };
1565
+
1566
+ type CommentResult =
1567
+
1568
+ ```
1569
+
1570
+ ### postInlineComments
1571
+
1572
+ **Type:** function
1573
+ **File:** /Users/debmukherjee/autodocs/src/github/pr-comments.ts
1574
+
1575
+ ```
1576
+ async function postInlineComments(config: PRCommentConfig, issues: DocumentationIssue[]): Promise<CommentResult[]>
1577
+ ```
1578
+
1579
+ Use this to post inline review comments on specific lines of a pull request, flagging documentation issues directly in the GitHub code review interface.
1580
+
1581
+ This function iterates over a list of documentation issues and creates inline PR comments at the exact file and line locations where problems were detected — ideal for automated documentation linting in CI pipelines.
1582
+
1583
+ ## Parameters
1584
+
1585
+ | Name | Type | Required | Description |
1586
+ |------|------|----------|-------------|
1587
+ | `config` | `PRCommentConfig`
1588
+
1589
+ **Example:**
1590
+ ```typescript
1591
+ // ─── Inline type definitions (no external imports needed) ───────────────────
1592
+
1593
+ type PRCommentConfig = {
1594
+ token: string;
1595
+ owner: string;
1596
+ repo: string;
1597
+ pullNumber: number;
1598
+ commitSha: string;
1599
+ };
1600
+
1601
+ type DocumentationIssue = {
1602
+ filePath: string;
1603
+ line: number;
1604
+ message: string;
1605
+ severity: 'e
1606
+ ```
1607
+
1608
+ ### analyzePRForDocs
1609
+
1610
+ **Type:** function
1611
+ **File:** /Users/debmukherjee/autodocs/src/github/pr-comments.ts
1612
+
1613
+ ```
1614
+ async function analyzePRForDocs(config: PRCommentConfig, _options: { checkExamples?: boolean } = {}): Promise<DocumentationIssue[]>
1615
+ ```
1616
+
1617
+ Use this to scan a pull request for documentation issues — missing docstrings, undocumented parameters, or incomplete return type descriptions — and get a structured list of problems to act on.
1618
+
1619
+ ## Parameters
1620
+
1621
+ | Name | Type | Required | Description |
1622
+ |------|------|----------|-------------|
1623
+ | `config` | `PRCommentConfig` | Yes | GitHub PR connection details including repo owner, repo name, PR number, and auth token |
1624
+ | `_options` | `{ checkExamples?: boolean }` | No | Additional analysis options
1625
+
1626
+ **Example:**
1627
+ ```typescript
1628
+ // Inline types (do not import from autodocs)
1629
+ type PRCommentConfig = {
1630
+ owner: string
1631
+ repo: string
1632
+ pullNumber: number
1633
+ token?: string
1634
+ }
1635
+
1636
+ type DocumentationIssue = {
1637
+ file: string
1638
+ line: number
1639
+ severity: 'error' | 'warning' | 'info'
1640
+ message: string
1641
+ ruleId: string
1642
+ }
1643
+
1644
+ // Simulated impleme
1645
+ ```
1646
+
1647
+ ### importConfluence
1648
+
1649
+ **Type:** function
1650
+ **File:** /Users/debmukherjee/autodocs/src/importers/confluence.ts
1651
+
1652
+ ```
1653
+ function importConfluence(dir: string, name?: string): ImportResult
1654
+ ```
1655
+
1656
+ Use this to convert a Confluence HTML space export into structured markdown pages, ready for use in documentation pipelines.
1657
+
1658
+ Given a directory containing a Confluence HTML export, `importConfluence` walks all HTML files, transforms Confluence-specific markup (callouts, tabs, code groups, etc.) into standard markdown, and returns a structured result with all imported pages and transformation statistics.
1659
+
1660
+ ## Parameters
1661
+
1662
+ | Name | Type | Required | Description |
1663
+ |------|------|----------|----------
1664
+
1665
+ ### detectFormat
1666
+
1667
+ **Type:** function
1668
+ **File:** /Users/debmukherjee/autodocs/src/importers/detect.ts
1669
+
1670
+ ```
1671
+ function detectFormat(dir: string): ImportFormat
1672
+ ```
1673
+
1674
+ Use this to automatically identify which documentation framework a project uses, so you can process or convert docs without requiring users to manually specify the format.
1675
+
1676
+ Given a directory path, `detectFormat` inspects marker files (like `mint.json`, `docs.json`, `_sidebar.md`, etc.) in priority order and returns the first matching format. This is ideal for CLI tools, migration scripts, or any workflow that needs to handle multiple doc formats transparently.
1677
+
1678
+ ### Parameters
1679
+
1680
+ | Name | Type | Re
1681
+
1682
+ **Example:**
1683
+ ```typescript
1684
+ import { existsSync, writeFileSync, mkdirSync, rmSync } from 'fs'
1685
+ import { join } from 'path'
1686
+ import * as os from 'os'
1687
+
1688
+ // --- Inline types (from autodocs, not imported) ---
1689
+ type ImportFormat = 'mintlify' | 'docusaurus' | 'gitbook' | 'docsify' | 'generic'
1690
+
1691
+ // --- Inline implementation of detectForma
1692
+ ```
1693
+
1694
+ ### isGitHubUrl
1695
+
1696
+ **Type:** function
1697
+ **File:** /Users/debmukherjee/autodocs/src/importers/detect.ts
1698
+
1699
+ ```
1700
+ function isGitHubUrl(input: string): boolean
1701
+ ```
1702
+
1703
+ Use this to validate whether a string is a GitHub repository or profile URL before processing it as a GitHub resource.
1704
+
1705
+ Useful for input validation pipelines, routing logic, or distinguishing GitHub URLs from local file paths or other URL types.
1706
+
1707
+ ## Parameters
1708
+
1709
+ | Name | Type | Required | Description |
1710
+ |------|------|----------|-------------|
1711
+ | `input` | `string` | ✅ | The string to test against the GitHub URL pattern |
1712
+
1713
+ ## Returns
1714
+
1715
+ | Value | Condition |
1716
+ |-------|-----------|
1717
+ | `true` | The strin
1718
+
1719
+ **Example:**
1720
+ ```typescript
1721
+ // Inline implementation — no external imports needed
1722
+ function isGitHubUrl(input: string): boolean {
1723
+ return /^https?:\/\/(www\.)?github\.com\//.test(input)
1724
+ }
1725
+
1726
+ // --- Example usage ---
1727
+
1728
+ const inputs = [
1729
+ 'https://github.com/microsoft/typescript', // ✅ valid HTTPS
1730
+ 'http://github.com/facebo
1731
+ ```
1732
+
1733
+ ### parseGitHubUrl
1734
+
1735
+ **Type:** function
1736
+ **File:** /Users/debmukherjee/autodocs/src/importers/detect.ts
1737
+
1738
+ ```
1739
+ function parseGitHubUrl(url: string): { owner: string; repo: string; path: string; ref: string }
1740
+ ```
1741
+
1742
+ Use this to extract the owner, repository name, branch/tag reference, and file path from a GitHub URL — useful when building tools that fetch repo contents, generate documentation links, or construct GitHub API requests.
1743
+
1744
+ Parses URLs in the format:
1745
+ `https://github.com/owner/repo/tree/branch/path/to/file`
1746
+
1747
+ | Name | Type | Required | Description |
1748
+ |------|------|----------|-------------|
1749
+ | `url` | `string` | ✅ | A full GitHub URL pointing to a repo, branch, or path |
1750
+
1751
+ ### Returns
1752
+
1753
+ An object with t
1754
+
1755
+ **Example:**
1756
+ ```typescript
1757
+ // Inline implementation of parseGitHubUrl (do not import from autodocs)
1758
+ function parseGitHubUrl(url: string): { owner: string; repo: string; path: string; ref: string } {
1759
+ const match = url.match(
1760
+ /^https?:\/\/(www\.)?github\.com\/([^/]+)\/([^/]+)(?:\/tree\/([^/]+)(?:\/(.*))?)?/
1761
+ )
1762
+ if (!mat
1763
+ ```
1764
+
1765
+ ### importDocusaurus
1766
+
1767
+ **Type:** function
1768
+ **File:** /Users/debmukherjee/autodocs/src/importers/docusaurus.ts
1769
+
1770
+ ```
1771
+ function importDocusaurus(dir: string, name?: string): ImportResult
1772
+ ```
1773
+
1774
+ Use this to convert a Docusaurus documentation directory into a structured, normalized `ImportResult` object — transforming admonitions, tabs, frontmatter, and image paths into a portable format ready for further processing or migration.
1775
+
1776
+ ### Parameters
1777
+
1778
+ | Name | Type | Required | Description |
1779
+ |------|------|----------|-------------|
1780
+ | `dir` | `string` | ✅ Yes | Absolute or relative path to the root of the Docusaurus project (the directory containing `docusaurus.config.js` or `docusaurus.config
1781
+
1782
+ ### importGitBook
1783
+
1784
+ **Type:** function
1785
+ **File:** /Users/debmukherjee/autodocs/src/importers/gitbook.ts
1786
+
1787
+ ```
1788
+ function importGitBook(dir: string, name?: string): ImportResult
1789
+ ```
1790
+
1791
+ Use this to convert a GitBook documentation directory into a structured import result, transforming GitBook-specific syntax (hints, tabs, steps, expandables, content refs, embeds) into a normalized format ready for further processing or migration.
1792
+
1793
+ ## Parameters
1794
+
1795
+ | Name | Type | Required | Description |
1796
+ |------|------|----------|-------------|
1797
+ | `dir` | `string` | ✅ Yes | Path to the root directory of the GitBook documentation |
1798
+ | `name` | `string` | ❌ No | Optional name to assign to the import
1799
+
1800
+ **Example:**
1801
+ ```typescript
1802
+ import { existsSync, mkdirSync, writeFileSync, rmSync } from 'fs'
1803
+ import { join } from 'path'
1804
+
1805
+ // ── Inline types (mirrors the real library's types) ──────────────────────────
1806
+
1807
+ interface TransformStats {
1808
+ callouts: number
1809
+ tabs: number
1810
+ codeGroups: number
1811
+ steps: number
1812
+ accordions: number
1813
+ im
1814
+ ```
1815
+
1816
+ ### importFromGitHub
1817
+
1818
+ **Type:** function
1819
+ **File:** /Users/debmukherjee/autodocs/src/importers/github.ts
1820
+
1821
+ ```
1822
+ async function importFromGitHub(owner: string, repo: string, path: string, ref: string, options?: { format?: ImportFormat; name?: string }): Promise<ImportResult>
1823
+ ```
1824
+
1825
+ Use this to pull documentation directly from a GitHub repository and import it into your system — no manual downloading or cloning required.
1826
+
1827
+ Given a repo owner, repository name, file path, and branch/tag/commit ref, this function fetches the content from GitHub and processes it as importable documentation.
1828
+
1829
+ ## Parameters
1830
+
1831
+ | Name | Type | Required | Description |
1832
+ |------|------|----------|-------------|
1833
+ | `owner` | `string` | ✅ | GitHub username or organization name (e.g. `"vercel"`) |
1834
+ | `repo`
1835
+
1836
+ **Example:**
1837
+ ```typescript
1838
+ // --- Inline types (mirroring the real library's shape) ---
1839
+ type ImportFormat = 'markdown' | 'openapi' | 'html' | 'text' | 'auto'
1840
+
1841
+ interface ImportResult {
1842
+ name: string
1843
+ format: ImportFormat
1844
+ pagesImported: number
1845
+ source: string
1846
+ success: boolean
1847
+ }
1848
+
1849
+ // --- Simulated implementation (replace w
1850
+ ```
1851
+
1852
+ ### runImport
1853
+
1854
+ **Type:** function
1855
+ **File:** /Users/debmukherjee/autodocs/src/importers/index.ts
1856
+
1857
+ ```
1858
+ function runImport(dir: string, format: ImportFormat, name?: string): ImportResult
1859
+ ```
1860
+
1861
+ Use this to automatically import and process a documentation directory based on its detected format (Mintlify, Docusaurus, GitBook, ReadMe, Confluence, or plain Markdown).
1862
+
1863
+ Instead of manually selecting the right importer, pass the directory path and detected format — `runImport` routes to the correct importer and returns a normalized result.
1864
+
1865
+ ## Parameters
1866
+
1867
+ | Name | Type | Required | Description |
1868
+ |------|------|----------|-------------|
1869
+ | `dir` | `string` | ✅ Yes | Path to the documentation di
1870
+
1871
+ **Example:**
1872
+ ```typescript
1873
+ // --- Inline types (mirrors autodocs internals) ---
1874
+ type ImportFormat = 'mintlify' | 'docusaurus' | 'gitbook' | 'readme' | 'confluence' | 'markdown'
1875
+
1876
+ interface ImportedPage {
1877
+ path: string
1878
+ title: string
1879
+ content: string
1880
+ }
1881
+
1882
+ interface ImportResult {
1883
+ name: string
1884
+ format: ImportFormat
1885
+ pages:
1886
+ ```
1887
+
1888
+ ### importMarkdown
1889
+
1890
+ **Type:** function
1891
+ **File:** /Users/debmukherjee/autodocs/src/importers/markdown.ts
1892
+
1893
+ ```
1894
+ function importMarkdown(dir: string, name?: string): ImportResult
1895
+ ```
1896
+
1897
+ Use this to convert a directory of Markdown or MDX files into a structured import result, where folder hierarchy becomes groups and individual files become pages.
1898
+
1899
+ This is the starting point when migrating a plain Markdown documentation site — it recursively scans the target directory, preserves your folder structure as navigation groups, and returns a normalized `ImportResult` ready for further processing or output.
1900
+
1901
+ ## Parameters
1902
+
1903
+ | Name | Type | Required | Description |
1904
+ |------|------|-------
1905
+
1906
+ ### importMintlify
1907
+
1908
+ **Type:** function
1909
+ **File:** /Users/debmukherjee/autodocs/src/importers/mintlify.ts
1910
+
1911
+ ```
1912
+ function importMintlify(dir: string, name?: string): ImportResult
1913
+ ```
1914
+
1915
+ Use this to convert a Mintlify documentation project into a standardized `ImportResult` format, ready for further processing or migration to another docs platform.
1916
+
1917
+ This function scans a Mintlify project directory, reads its configuration, transforms MDX components (callouts, tabs, code groups, steps, accordions), and returns all pages with normalized frontmatter and rewritten image paths.
1918
+
1919
+ ## Parameters
1920
+
1921
+ | Name | Type | Required | Description |
1922
+ |------|------|----------|-------------|
1923
+ | `dir` |
1924
+
1925
+ ### importNotion
1926
+
1927
+ **Type:** function
1928
+ **File:** /Users/debmukherjee/autodocs/src/importers/notion.ts
1929
+
1930
+ ```
1931
+ function importNotion(dir: string, name?: string): ImportResult
1932
+ ```
1933
+
1934
+ Use this to convert a Notion export folder into structured, importable page data — stripping UUIDs, normalizing frontmatter, and transforming Notion-specific syntax into clean markdown.
1935
+
1936
+ This is the entry point for processing a Notion HTML/Markdown export. Point it at the extracted export directory and it returns all discovered pages with their transformed content and transformation statistics.
1937
+
1938
+ ## Parameters
1939
+
1940
+ | Name | Type | Required | Description |
1941
+ |------|------|----------|-------------|
1942
+ | `d
1943
+
1944
+ ### importReadme
1945
+
1946
+ **Type:** function
1947
+ **File:** /Users/debmukherjee/autodocs/src/importers/readme.ts
1948
+
1949
+ ```
1950
+ function importReadme(dir: string, name?: string): ImportResult
1951
+ ```
1952
+
1953
+ Use this to convert a ReadMe.io documentation export into a structured import result, transforming ReadMe-specific markdown syntax (callouts, code blocks, frontmatter) into a normalized format ready for further processing or migration.
1954
+
1955
+ ## Parameters
1956
+
1957
+ | Name | Type | Required | Description |
1958
+ |------|------|----------|-------------|
1959
+ | `dir` | `string` | ✅ Yes | Path to the root directory of the ReadMe.io export. ReadMe organizes exports into category folders, each containing an `_order.yaml` file
1960
+
1961
+ ### transformMintlifyCallouts
1962
+
1963
+ **Type:** function
1964
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
1965
+
1966
+ ```
1967
+ function transformMintlifyCallouts(content: string): string
1968
+ ```
1969
+
1970
+ Use this to convert Mintlify-flavored callout components (`<Note>`, `<Warning>`, `<Tip>`, `<Info>`, `<Check>`) into a unified `<Callout type="...">` format during documentation migration or preprocessing.
1971
+
1972
+ This is useful when migrating docs from Mintlify to another platform (e.g., Nextra, Fumadocs) that uses a generic `<Callout>` component with a `type` prop instead of named tags.
1973
+
1974
+ ### Parameters
1975
+
1976
+ | Name | Type | Required | Description |
1977
+ |------|------|----------|-------------|
1978
+ | `content` | `st
1979
+
1980
+ **Example:**
1981
+ ```typescript
1982
+ // Inline the callout tag mapping (mirrors the library's internal map)
1983
+ const MINTLIFY_CALLOUT_MAP: Record<string, string> = {
1984
+ Note: 'note',
1985
+ Warning: 'warning',
1986
+ Tip: 'tip',
1987
+ Info: 'info',
1988
+ Check: 'check',
1989
+ }
1990
+
1991
+ // Self-contained implementation of transformMintlifyCallouts
1992
+ function transformMintl
1993
+ ```
1994
+
1995
+ ### transformDocusaurusAdmonitions
1996
+
1997
+ **Type:** function
1998
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
1999
+
2000
+ ```
2001
+ function transformDocusaurusAdmonitions(content: string): string
2002
+ ```
2003
+
2004
+ Use this to convert Docusaurus admonition blocks (:::note, :::tip, :::danger, etc.) into a standardized callout format for rendering in other documentation systems.
2005
+
2006
+ This is useful when migrating or syncing Docusaurus docs to platforms that use a different callout/admonition syntax — the function handles all standard Docusaurus admonition types and optional custom titles.
2007
+
2008
+ ## Parameters
2009
+
2010
+ | Name | Type | Required | Description |
2011
+ |------|------|----------|-------------|
2012
+ | content | `string` | ✅ |
2013
+
2014
+ **Example:**
2015
+ ```typescript
2016
+ // Inline the admonition type mapping (mirrors the real implementation)
2017
+ const DOCUSAURUS_ADMONITION_MAP: Record<string, string> = {
2018
+ note: 'note',
2019
+ tip: 'tip',
2020
+ info: 'info',
2021
+ caution: 'warning',
2022
+ danger: 'danger',
2023
+ warning: 'warning',
2024
+ }
2025
+
2026
+ // Self-contained implementation of transformDocusaurus
2027
+ ```
2028
+
2029
+ ### transformGitBookHints
2030
+
2031
+ **Type:** function
2032
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2033
+
2034
+ ```
2035
+ function transformGitBookHints(content: string): string
2036
+ ```
2037
+
2038
+ Use this to convert GitBook hint/callout blocks into `<Callout>` JSX components during documentation migration or preprocessing.
2039
+
2040
+ GitBook uses a custom `{% hint style="..." %}` syntax that won't render in standard MDX or React-based doc systems. This function transforms those blocks into `<Callout type="...">` components, preserving the hint style and content.
2041
+
2042
+ **Supported style mappings** (based on typical GitBook hint styles):
2043
+ | GitBook Style | Callout Type |
2044
+ |---------------|--------------|
2045
+ |
2046
+
2047
+ **Example:**
2048
+ ```typescript
2049
+ // Inline the hint style map (mirrors the real implementation)
2050
+ const GITBOOK_HINT_MAP: Record<string, string> = {
2051
+ info: 'info',
2052
+ warning: 'warning',
2053
+ danger: 'danger',
2054
+ success: 'success',
2055
+ }
2056
+
2057
+ // Self-contained implementation of transformGitBookHints
2058
+ function transformGitBookHints(content: strin
2059
+ ```
2060
+
2061
+ ### transformReadmeCallouts
2062
+
2063
+ **Type:** function
2064
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2065
+
2066
+ ```
2067
+ function transformReadmeCallouts(content: string): string
2068
+ ```
2069
+
2070
+ Use this to convert ReadMe RDMD-style callout blocks (using emoji prefixes) into standard markdown or HTML callout components — ideal for preprocessing `.md` files exported from ReadMe before rendering them in your own docs pipeline.
2071
+
2072
+ ### Parameters
2073
+
2074
+ | Name | Type | Required | Description |
2075
+ |------|------|----------|-------------|
2076
+ | `content` | `string` | ✅ | Raw markdown string containing ReadMe RDMD callout syntax (e.g., `> 📘 Title\n> body text`) |
2077
+
2078
+ ### Returns
2079
+
2080
+ | Condition | Returns |
2081
+ |-----
2082
+
2083
+ **Example:**
2084
+ ```typescript
2085
+ // Inline the emoji map and transformation logic (self-contained, no imports needed)
2086
+ const README_EMOJI_MAP: Record<string, string> = {
2087
+ '📘': 'info',
2088
+ '👍': 'success',
2089
+ '🚧': 'warning',
2090
+ '❗': 'danger',
2091
+ }
2092
+
2093
+ // Inline implementation of transformReadmeCallouts
2094
+ function transformReadmeCallouts(conte
2095
+ ```
2096
+
2097
+ ### transformNotionCallouts
2098
+
2099
+ **Type:** function
2100
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2101
+
2102
+ ```
2103
+ function transformNotionCallouts(content: string): string
2104
+ ```
2105
+
2106
+ Use this to convert Notion-style callout markup — both `<aside>` HTML blocks and `:::callout` fenced syntax — into a normalized format suitable for rendering or further processing.
2107
+
2108
+ This is especially useful when parsing exported Notion content that mixes raw HTML callouts with Markdown-style callout blocks, ensuring consistent output regardless of which format Notion used.
2109
+
2110
+ ### Parameters
2111
+
2112
+ | Name | Type | Required | Description |
2113
+ |------|------|----------|-------------|
2114
+ | `content` | `string` |
2115
+
2116
+ **Example:**
2117
+ ```typescript
2118
+ // Inline implementation of transformNotionCallouts for demonstration
2119
+ // (mirrors the real behavior: converts Notion callout formats to normalized blockquotes)
2120
+ function transformNotionCallouts(content: string): string {
2121
+ // Transform <aside>...</aside> HTML blocks
2122
+ content = content.replace(
2123
+ /
2124
+ ```
2125
+
2126
+ ### transformConfluenceCallouts
2127
+
2128
+ **Type:** function
2129
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2130
+
2131
+ ```
2132
+ function transformConfluenceCallouts(content: string): string
2133
+ ```
2134
+
2135
+ Use this to convert Confluence structured macro callouts (`info`, `note`, `warning`, `tip`) into clean `<Callout>` components suitable for rendering in documentation systems like Nextra or MDX.
2136
+
2137
+ When migrating Confluence pages to Markdown/MDX, callout macros come through as verbose XML-like `<ac:structured-macro>` tags. This function strips that boilerplate and outputs a compact, framework-friendly `<Callout type="...">` element with the inner text content preserved.
2138
+
2139
+ ## Parameters
2140
+
2141
+ | Name | Typ
2142
+
2143
+ **Example:**
2144
+ ```typescript
2145
+ // Inline implementation of the helper and main function (self-contained)
2146
+ function stripHtmlTags(html: string): string {
2147
+ return html.replace(/<[^>]*>/g, '')
2148
+ }
2149
+
2150
+ function transformConfluenceCallouts(content: string): string {
2151
+ return content.replace(
2152
+ /<ac:structured-macro[^>]*ac:name="(info|not
2153
+ ```
2154
+
2155
+ ### transformMintlifyTabs
2156
+
2157
+ **Type:** function
2158
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2159
+
2160
+ ```
2161
+ function transformMintlifyTabs(content: string): string
2162
+ ```
2163
+
2164
+ Use this to convert Mintlify-flavored `<Tabs>/<Tab>` JSX syntax into standard Markdown or a compatible tab format — useful when migrating docs from Mintlify to another platform or pre-processing MDX content.
2165
+
2166
+ ### Parameters
2167
+
2168
+ | Name | Type | Required | Description |
2169
+ |------|------|----------|-------------|
2170
+ | `content` | `string` | ✅ | Raw documentation string containing Mintlify `<Tabs>` and `<Tab>` components |
2171
+
2172
+ ### Returns
2173
+
2174
+ | Condition | Return Value |
2175
+ |-----------|-------------|
2176
+ | Content cont
2177
+
2178
+ **Example:**
2179
+ ```typescript
2180
+ // Inline implementation of transformMintlifyTabs (self-contained, no imports needed)
2181
+ function transformMintlifyTabs(content: string): string {
2182
+ return content.replace(
2183
+ /<Tabs>([\s\S]*?)<\/Tabs>/g,
2184
+ (_match, inner: string) => {
2185
+ const tabs: { title: string; content: string }[] = []
2186
+
2187
+ ```
2188
+
2189
+ ### transformDocusaurusTabs
2190
+
2191
+ **Type:** function
2192
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2193
+
2194
+ ```
2195
+ function transformDocusaurusTabs(content: string): string
2196
+ ```
2197
+
2198
+ Use this to convert Docusaurus `<Tabs>` / `<TabItem>` JSX syntax into plain markdown or a renderable alternative — useful when migrating Docusaurus docs to another format or stripping framework-specific markup from content.
2199
+
2200
+ ### Parameters
2201
+
2202
+ | Name | Type | Required | Description |
2203
+ |------|------|----------|-------------|
2204
+ | `content` | `string` | ✅ | Raw documentation string containing Docusaurus `<Tabs>` and `<TabItem>` JSX elements |
2205
+
2206
+ ### Returns
2207
+
2208
+ | Condition | Return Value |
2209
+ |-----------|-----
2210
+
2211
+ **Example:**
2212
+ ```typescript
2213
+ // Inline implementation of transformDocusaurusTabs (self-contained, no imports needed)
2214
+ function transformDocusaurusTabs(content: string): string {
2215
+ return content.replace(
2216
+ /<Tabs[^>]*>([\s\S]*?)<\/Tabs>/g,
2217
+ (_match, inner: string) => {
2218
+ const tabs: { value: string; label: string; conte
2219
+ ```
2220
+
2221
+ ### transformGitBookTabs
2222
+
2223
+ **Type:** function
2224
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2225
+
2226
+ ```
2227
+ function transformGitBookTabs(content: string): string
2228
+ ```
2229
+
2230
+ Use this to convert GitBook tab syntax into clean markdown, stripping the `{% tabs %}` / `{% tab %}` / `{% endtab %}` / `{% endtabs %}` block tags while preserving each tab's title and content.
2231
+
2232
+ This is useful when migrating GitBook documentation to standard markdown or when rendering GitBook-flavored content in environments that don't support GitBook's templating syntax.
2233
+
2234
+ ## Parameters
2235
+
2236
+ | Name | Type | Required | Description |
2237
+ |------|------|----------|-------------|
2238
+ | `content` | `string` | ✅
2239
+
2240
+ **Example:**
2241
+ ```typescript
2242
+ // Inline implementation of transformGitBookTabs (no external imports needed)
2243
+ function transformGitBookTabs(content: string): string {
2244
+ return content.replace(
2245
+ /\{%\s*tabs\s*%\}([\s\S]*?)\{%\s*endtabs\s*%\}/g,
2246
+ (_match, inner: string) => {
2247
+ const tabs: { title: string; content: string }
2248
+ ```
2249
+
2250
+ ### transformReadmeCodeBlocks
2251
+
2252
+ **Type:** function
2253
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2254
+
2255
+ ```
2256
+ function transformReadmeCodeBlocks(content: string): string
2257
+ ```
2258
+
2259
+ Use this to convert ReadMe.io's proprietary `[block:code]` syntax into standard `<CodeGroup>` components for modern documentation platforms.
2260
+
2261
+ When migrating content from ReadMe.io, code blocks are stored as JSON-wrapped `[block:code]...[/block]` tags. This function parses those blocks and transforms them into portable `<CodeGroup>` elements that work with MDX-based doc systems like Mintlify or Nextra.
2262
+
2263
+ ## Parameters
2264
+
2265
+ | Name | Type | Required | Description |
2266
+ |------|------|----------|------------
2267
+
2268
+ **Example:**
2269
+ ```typescript
2270
+ // Inline implementation of transformReadmeCodeBlocks
2271
+ // (mirrors the real function behavior for demonstration)
2272
+
2273
+ function transformReadmeCodeBlocks(content: string): string {
2274
+ return content.replace(
2275
+ /\[block:code\]\n?([\s\S]*?)\n?\[\/block\]/g,
2276
+ (_match, jsonStr: string) => {
2277
+ try {
2278
+
2279
+ ```
2280
+
2281
+ ### transformGitBookSteps
2282
+
2283
+ **Type:** function
2284
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2285
+
2286
+ ```
2287
+ function transformGitBookSteps(content: string): string
2288
+ ```
2289
+
2290
+ Use this to convert GitBook stepper/step syntax into clean markdown, stripping the `{% stepper %}`, `{% step %}`, `{% endstep %}`, and `{% endstepper %}` tags while preserving the step content in a readable format.
2291
+
2292
+ This is useful when migrating GitBook documentation to standard markdown or rendering GitBook content in environments that don't support GitBook's custom block syntax.
2293
+
2294
+ ### Parameters
2295
+
2296
+ | Name | Type | Required | Description |
2297
+ |------|------|----------|-------------|
2298
+ | `content` | `st
2299
+
2300
+ **Example:**
2301
+ ```typescript
2302
+ // Inline implementation of transformGitBookSteps (self-contained, no imports needed)
2303
+ function transformGitBookSteps(content: string): string {
2304
+ return content.replace(
2305
+ /\{%\s*stepper\s*%\}([\s\S]*?)\{%\s*endstepper\s*%\}/g,
2306
+ (_match, inner: string) => {
2307
+ const steps = inner
2308
+ .sp
2309
+ ```
2310
+
2311
+ ### transformGitBookExpandable
2312
+
2313
+ **Type:** function
2314
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2315
+
2316
+ ```
2317
+ function transformGitBookExpandable(content: string): string
2318
+ ```
2319
+
2320
+ Use this to convert GitBook expandable blocks into Accordion components for rendering in documentation frameworks that support `<Accordion>` syntax (e.g., Mintlify).
2321
+
2322
+ Transforms `{% expandable title="X" %}...{% endexpandable %}` GitBook shortcodes into `<Accordion title="X">...</Accordion>` HTML/JSX elements. Handles multiline content and multiple expandable blocks in a single pass.
2323
+
2324
+ ### Parameters
2325
+
2326
+ | Name | Type | Required | Description |
2327
+ |------|------|----------|-------------|
2328
+ | `content` | `
2329
+
2330
+ **Example:**
2331
+ ```typescript
2332
+ // Inline implementation of transformGitBookExpandable
2333
+ function transformGitBookExpandable(content: string): string {
2334
+ return content.replace(
2335
+ /\{%\s*expandable\s+title="([^"]+)"\s*%\}([\s\S]*?)\{%\s*endexpandable\s*%\}/g,
2336
+ (_match, title: string, body: string) =>
2337
+ `<Accordion title="${
2338
+ ```
2339
+
2340
+ ### transformGitBookContentRef
2341
+
2342
+ **Type:** function
2343
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2344
+
2345
+ ```
2346
+ function transformGitBookContentRef(content: string): string
2347
+ ```
2348
+
2349
+ Use this to convert GitBook `content-ref` shortcode blocks into standard markdown links during documentation migration or content processing pipelines.
2350
+
2351
+ GitBook uses a proprietary `{% content-ref %}...{% endcontent-ref %}` block syntax to create page references. This function strips that syntax and produces a clean `[label](url)` markdown link, where the label is automatically derived from the URL's filename (with `.md` extension removed).
2352
+
2353
+ **Parameters**
2354
+
2355
+ | Name | Type | Required | Description
2356
+
2357
+ **Example:**
2358
+ ```typescript
2359
+ // Inline implementation — no external imports needed
2360
+ function transformGitBookContentRef(content: string): string {
2361
+ return content.replace(
2362
+ /\{%\s*content-ref\s+url="([^"]+)"\s*%\}[\s\S]*?\{%\s*endcontent-ref\s*%\}/g,
2363
+ (_match, url: string) => {
2364
+ const label = url.replace(/\.md$/, '')
2365
+ ```
2366
+
2367
+ ### transformGitBookEmbed
2368
+
2369
+ **Type:** function
2370
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2371
+
2372
+ ```
2373
+ function transformGitBookEmbed(content: string): string
2374
+ ```
2375
+
2376
+ Use this to strip GitBook `{% embed url="..." %}` syntax from content, replacing it with plain URLs for rendering in non-GitBook environments.
2377
+
2378
+ This is useful when migrating GitBook documentation to other platforms, or when processing GitBook markdown files that contain embed tags that would appear as raw syntax instead of rendered links.
2379
+
2380
+ ### Parameters
2381
+
2382
+ | Name | Type | Required | Description |
2383
+ |------|------|----------|-------------|
2384
+ | `content` | `string` | ✅ | A string containing GitBook emb
2385
+
2386
+ **Example:**
2387
+ ```typescript
2388
+ // Inline implementation of transformGitBookEmbed
2389
+ function transformGitBookEmbed(content: string): string {
2390
+ return content.replace(
2391
+ /\{%\s*embed\s+url="([^"]+)"\s*%\}/g,
2392
+ (_match, url: string) => url
2393
+ )
2394
+ }
2395
+
2396
+ // --- Examples ---
2397
+
2398
+ // 1. Single embed tag
2399
+ const singleEmbed = `Check out this reso
2400
+ ```
2401
+
2402
+ ### transformNotionToggles
2403
+
2404
+ **Type:** function
2405
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2406
+
2407
+ ```
2408
+ function transformNotionToggles(content: string): string
2409
+ ```
2410
+
2411
+ Use this to convert Notion-exported toggle blocks (HTML `<details>`/`<summary>` elements) into `<Accordion>` components for MDX or documentation frameworks like Mintlify or Docusaurus.
2412
+
2413
+ When you export content from Notion, toggles become `<details><summary>Title</summary>content</details>` HTML. This function transforms all of them in a single pass into `<Accordion title="...">` components ready for rendering.
2414
+
2415
+ ### Parameters
2416
+
2417
+ | Name | Type | Required | Description |
2418
+ |------|------|----------|--
2419
+
2420
+ **Example:**
2421
+ ```typescript
2422
+ // Inline implementation — no imports needed
2423
+ function transformNotionToggles(content: string): string {
2424
+ return content.replace(
2425
+ /<details>\s*<summary>([\s\S]*?)<\/summary>([\s\S]*?)<\/details>/g,
2426
+ (_match, title: string, body: string) =>
2427
+ `<Accordion title="${title.trim()}">\n${body.tr
2428
+ ```
2429
+
2430
+ ### transformConfluenceHtml
2431
+
2432
+ **Type:** function
2433
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2434
+
2435
+ ```
2436
+ function transformConfluenceHtml(content: string): string
2437
+ ```
2438
+
2439
+ Use this to convert Confluence HTML pages (including Atlassian Confluence macros) into clean, readable Markdown strings — ideal for ingesting Confluence content into AI pipelines, search indexes, or documentation systems.
2440
+
2441
+ This function handles:
2442
+ - `ac:structured-macro` code blocks (with optional language tags) → fenced Markdown code blocks
2443
+ - Common HTML elements → Markdown equivalents
2444
+
2445
+ | Name | Type | Required | Description |
2446
+ |------|------|----------|-------------|
2447
+ | `content` | `string` | ✅ |
2448
+
2449
+ **Example:**
2450
+ ```typescript
2451
+ // Inline implementation of transformConfluenceHtml (self-contained, no imports needed)
2452
+ function transformConfluenceHtml(content: string): string {
2453
+ // Code macros: <ac:structured-macro ac:name="code"> with optional language
2454
+ content = content.replace(
2455
+ /<ac:structured-macro[^>]*ac:name="code"[
2456
+ ```
2457
+
2458
+ ### stripDocusaurusImports
2459
+
2460
+ **Type:** function
2461
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2462
+
2463
+ ```
2464
+ function stripDocusaurusImports(content: string): string
2465
+ ```
2466
+
2467
+ Use this to clean Docusaurus-specific theme import statements from MDX/markdown content before processing it in non-Docusaurus environments, or when extracting plain content from Docusaurus documentation files.
2468
+
2469
+ Strips all lines matching the pattern `import ... from '@theme/...'` — the special Docusaurus theme component imports that would cause errors or noise outside of a Docusaurus build context.
2470
+
2471
+ ## Parameters
2472
+
2473
+ | Name | Type | Required | Description |
2474
+ |------|------|----------|-------------|
2475
+
2476
+
2477
+ **Example:**
2478
+ ```typescript
2479
+ // Inline implementation — no external imports needed
2480
+ function stripDocusaurusImports(content: string): string {
2481
+ return content.replace(/^import\s+.*from\s+['"]@theme\/.*['"];?\s*\n?/gm, '')
2482
+ }
2483
+
2484
+ // --- Example usage ---
2485
+
2486
+ const rawMdxContent = `import Tabs from '@theme/Tabs';
2487
+ import TabItem from '@t
2488
+ ```
2489
+
2490
+ ### normalizeFrontmatter
2491
+
2492
+ **Type:** function
2493
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2494
+
2495
+ ```
2496
+ function normalizeFrontmatter(content: string, defaults?: FrontmatterDefaults): string
2497
+ ```
2498
+
2499
+ Use this to standardize frontmatter fields in markdown content to Skrypt format, optionally injecting default values when fields are missing.
2500
+
2501
+ This is useful when processing markdown files from multiple sources that may use inconsistent frontmatter conventions — it normalizes them into a predictable structure while preserving the document body.
2502
+
2503
+ ## Parameters
2504
+
2505
+ | Name | Type | Required | Description |
2506
+ |------|------|----------|-------------|
2507
+ | `content` | `string` | ✅ | Full markdown string, incl
2508
+
2509
+ **Example:**
2510
+ ```typescript
2511
+ // Inline types (do not import from autodocs)
2512
+ type FrontmatterDefaults = {
2513
+ title?: string
2514
+ description?: string
2515
+ tags?: string[]
2516
+ author?: string
2517
+ date?: string
2518
+ [key: string]: unknown
2519
+ }
2520
+
2521
+ // --- Simulated implementation of normalizeFrontmatter ---
2522
+ function parseFrontmatterRaw(content: string)
2523
+ ```
2524
+
2525
+ ### rewriteImagePaths
2526
+
2527
+ **Type:** function
2528
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2529
+
2530
+ ```
2531
+ function rewriteImagePaths(content: string, mapping: Map<string, string>): string
2532
+ ```
2533
+
2534
+ Use this to update image paths in documentation content after assets have been copied to a new location. When you move or rename image files during a build process, this function rewrites all references in your content string to point to the new paths.
2535
+
2536
+ ## Parameters
2537
+
2538
+ | Name | Type | Required | Description |
2539
+ |------|------|----------|-------------|
2540
+ | `content` | `string` | ✅ | The raw content string (e.g., Markdown or HTML) containing image path references to be updated |
2541
+ | `mapping` | `Map<stri
2542
+
2543
+ **Example:**
2544
+ ```typescript
2545
+ // Inline implementation — no external imports needed
2546
+ function rewriteImagePaths(content: string, mapping: Map<string, string>): string {
2547
+ for (const [oldPath, newPath] of mapping) {
2548
+ content = content.replaceAll(oldPath, newPath)
2549
+ }
2550
+ return content
2551
+ }
2552
+
2553
+ // Simulate a docs page with several imag
2554
+ ```
2555
+
2556
+ ### stripNotionUUIDs
2557
+
2558
+ **Type:** function
2559
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2560
+
2561
+ ```
2562
+ function stripNotionUUIDs(filename: string): string
2563
+ ```
2564
+
2565
+ Use this to clean up Notion export filenames by removing the 32-character hex UUID suffixes that Notion automatically appends to every file and folder name.
2566
+
2567
+ When you export content from Notion, filenames look like `My Page a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4.md`. This function strips those suffixes, giving you human-readable filenames like `My Page.md`.
2568
+
2569
+ ## Parameters
2570
+
2571
+ | Name | Type | Required | Description |
2572
+ |------|------|----------|-------------|
2573
+ | `filename` | `string` | ✅ | The Notion-exporte
2574
+
2575
+ **Example:**
2576
+ ```typescript
2577
+ // Inline implementation — no external imports needed
2578
+ function stripNotionUUIDs(filename: string): string {
2579
+ return filename.replace(/\s+[0-9a-f]{32}/g, '')
2580
+ }
2581
+
2582
+ async function main() {
2583
+ try {
2584
+ // Basic usage: single file with UUID suffix
2585
+ const raw = 'Getting Started a1b2c3d4e5f6a1b2c3d4e5f6a
2586
+ ```
2587
+
2588
+ ### getSortWeight
2589
+
2590
+ **Type:** function
2591
+ **File:** /Users/debmukherjee/autodocs/src/importers/transform.ts
2592
+
2593
+ ```
2594
+ function getSortWeight(content: string): number
2595
+ ```
2596
+
2597
+ Use this to determine the sort order of a documentation file by extracting its position weight from frontmatter metadata. Returns a numeric weight so you can sort an array of markdown files into the correct sidebar order.
2598
+
2599
+ Supports the following frontmatter keys (in priority order): `sidebar_position`, `order`, `weight`, `position`.
2600
+
2601
+ ## Parameters
2602
+
2603
+ | Name | Type | Required | Description |
2604
+ |------|------|----------|-------------|
2605
+ | `content` | `string` | Yes | Raw markdown/MDX file content, inclu
2606
+
2607
+ **Example:**
2608
+ ```typescript
2609
+ // Inline frontmatter parser (simulates gray-matter / parseFrontmatterRaw)
2610
+ function parseFrontmatterRaw(content: string): { data: Record<string, unknown> | null } {
2611
+ const match = content.match(/^---\n([\s\S]*?)\n---/)
2612
+ if (!match) return { data: null }
2613
+
2614
+ const yaml = match[1]
2615
+ const data: Recor
2616
+ ```
2617
+
2618
+ ### AnthropicClient
2619
+
2620
+ **Type:** class
2621
+ **File:** /Users/debmukherjee/autodocs/src/llm/anthropic-client.ts
2622
+
2623
+ ```
2624
+ class AnthropicClient implements LLMClient
2625
+ ```
2626
+
2627
+ Use this to send prompts to Anthropic's Claude models and receive structured completions — with automatic retries built in.
2628
+
2629
+ `AnthropicClient` wraps the Anthropic SDK and implements a common `LLMClient` interface, making it easy to swap between LLM providers without changing your application logic.
2630
+
2631
+ ## Constructor Parameters
2632
+
2633
+ | Name | Type | Required | Description |
2634
+ |------|------|----------|-------------|
2635
+ | `config.model` | `string` | Yes | The Claude model to use (e.g. `"claude-3-5-sonnet-2024
2636
+
2637
+ **Example:**
2638
+ ```typescript
2639
+ // ── Inline types (no external imports needed) ──────────────────────────────
2640
+
2641
+ type LLMProvider = 'anthropic' | 'openai'
2642
+
2643
+ type LLMClientConfig = {
2644
+ model: string
2645
+ apiKey: string
2646
+ maxRetries?: number
2647
+ }
2648
+
2649
+ type CompletionRequest = {
2650
+ messages: Array<{ role: 'user' | 'assistant'; content: string }>
2651
+
2652
+ ```
2653
+
2654
+ ### constructor
2655
+
2656
+ **Type:** method
2657
+ **File:** /Users/debmukherjee/autodocs/src/llm/anthropic-client.ts
2658
+
2659
+ ```
2660
+ constructor(config: LLMClientConfig)
2661
+ ```
2662
+
2663
+ Use this to create an Anthropic-backed LLM client that handles retries and model configuration for sending completion requests.
2664
+
2665
+ The `AnthropicClient` constructor initializes a client instance configured with your Anthropic API key, target model, and retry behavior. It wraps the Anthropic SDK to provide a consistent interface for making LLM calls.
2666
+
2667
+ ### Parameters
2668
+
2669
+ | Name | Type | Required | Description |
2670
+ |------|------|----------|-------------|
2671
+ | `config.apiKey` | `string` | Yes | Your Anthropic
2672
+
2673
+ **Example:**
2674
+ ```typescript
2675
+ // Inline type definitions (do not import from autodocs)
2676
+ type LLMProvider = 'anthropic' | 'openai'
2677
+
2678
+ interface LLMClientConfig {
2679
+ apiKey: string
2680
+ model: string
2681
+ maxRetries?: number
2682
+ }
2683
+
2684
+ interface CompletionRequest {
2685
+ prompt: string
2686
+ maxTokens?: number
2687
+ }
2688
+
2689
+ interface CompletionResponse {
2690
+ text: stri
2691
+ ```
2692
+
2693
+ ### isConfigured
2694
+
2695
+ **Type:** method
2696
+ **File:** /Users/debmukherjee/autodocs/src/llm/anthropic-client.ts
2697
+
2698
+ ```
2699
+ isConfigured(): boolean
2700
+ ```
2701
+
2702
+ Use this to verify that an `AnthropicClient` instance is ready to make API calls before attempting completions.
2703
+
2704
+ This method acts as a readiness check — it confirms the client has been initialized and the underlying Anthropic SDK has taken responsibility for credential validation. Call it as a guard before executing requests in conditional flows or health checks.
2705
+
2706
+ **Returns**
2707
+
2708
+ | Value | Condition |
2709
+ |-------|-----------|
2710
+ | `true` | Always — the client is initialized and the Anthropic SDK handles
2711
+
2712
+ **Example:**
2713
+ ```typescript
2714
+ // Inline types to simulate AnthropicClient behavior
2715
+ interface LLMClientConfig {
2716
+ apiKey: string
2717
+ model?: string
2718
+ timeout?: number
2719
+ maxRetries?: number
2720
+ }
2721
+
2722
+ // Simulated AnthropicClient class (self-contained, no external imports)
2723
+ class AnthropicClient {
2724
+ private apiKey: string
2725
+ private model: st
2726
+ ```
2727
+
2728
+ ### complete
2729
+
2730
+ **Type:** method
2731
+ **File:** /Users/debmukherjee/autodocs/src/llm/anthropic-client.ts
2732
+
2733
+ ```
2734
+ async complete(request: CompletionRequest): Promise<CompletionResponse>
2735
+ ```
2736
+
2737
+ Use this to send a conversation to Anthropic's Claude models and receive a completion response, handling system prompts and multi-turn conversations automatically.
2738
+
2739
+ This method separates system messages from conversation messages internally, so you can pass a unified message array without pre-processing. It wraps Anthropic's SDK and returns a normalized `CompletionResponse` regardless of which Claude model you target.
2740
+
2741
+ ## Parameters
2742
+
2743
+ | Name | Type | Required | Description |
2744
+ |------|------|------
2745
+
2746
+ **Example:**
2747
+ ```typescript
2748
+ // ── Inline types (no external imports needed) ──────────────────────────────
2749
+
2750
+ type MessageRole = 'system' | 'user' | 'assistant'
2751
+
2752
+ interface Message {
2753
+ role: MessageRole
2754
+ content: string
2755
+ }
2756
+
2757
+ interface CompletionRequest {
2758
+ messages: Message[]
2759
+ model?: string
2760
+ maxTokens?: number
2761
+ temperature?: n
2762
+ ```
2763
+
2764
+ ### createLLMClient
2765
+
2766
+ **Type:** function
2767
+ **File:** /Users/debmukherjee/autodocs/src/llm/index.ts
2768
+
2769
+ ```
2770
+ function createLLMClient(config: {
2771
+ provider: LLMProvider
2772
+ model: string
2773
+ baseUrl?: string
2774
+ timeout?: number
2775
+ maxRetries?: number
2776
+ }): LLMClient
2777
+ ```
2778
+
2779
+ Use this to initialize a typed LLM client for a specific AI provider (OpenAI, Anthropic, etc.) with built-in retry and timeout handling.
2780
+
2781
+ This is your entry point for all LLM interactions — call it once at startup, then reuse the returned client across your application to send prompts and receive completions.
2782
+
2783
+ ## Parameters
2784
+
2785
+ | Name | Type | Required | Description |
2786
+ |------|------|----------|-------------|
2787
+ | `config.provider` | `LLMProvider` | ✅ Yes | The AI provider to use. Accepted values: `"op
2788
+
2789
+ **Example:**
2790
+ ```typescript
2791
+ // --- Inline types (mirrors the real library's shape) ---
2792
+ type LLMProvider = "openai" | "anthropic" | "azure"
2793
+
2794
+ interface Message {
2795
+ role: "user" | "assistant" | "system"
2796
+ content: string
2797
+ }
2798
+
2799
+ interface CompletionResponse {
2800
+ id: string
2801
+ content: string
2802
+ model: string
2803
+ usage: { promptTokens: numb
2804
+ ```
2805
+
2806
+ ### generateDocumentation
2807
+
2808
+ **Type:** function
2809
+ **File:** /Users/debmukherjee/autodocs/src/llm/index.ts
2810
+
2811
+ ```
2812
+ async function generateDocumentation(client: LLMClient, element: ElementContext, options?: { multiLanguage?: boolean }): Promise<GeneratedDocResult>
2813
+ ```
2814
+
2815
+ Use this to automatically generate documentation for a code element (function, class, method, etc.) using an LLM client, with optional multi-language support.
2816
+
2817
+ This is the primary entry point for producing structured documentation output from parsed code context. Pass in your configured LLM client and a description of the code element, and receive a ready-to-use documentation result.
2818
+
2819
+ ## Parameters
2820
+
2821
+ | Name | Type | Required | Description |
2822
+ |------|------|----------|-------------|
2823
+ | `client` | `L
2824
+
2825
+ **Example:**
2826
+ ```typescript
2827
+ // ─── Inline type definitions (no external imports needed) ───────────────────
2828
+
2829
+ type LLMMessage = { role: 'user' | 'assistant' | 'system'; content: string }
2830
+
2831
+ interface LLMClient {
2832
+ complete(messages: LLMMessage[]): Promise<string>
2833
+ }
2834
+
2835
+ interface ElementContext {
2836
+ name: string
2837
+ signature: string
2838
+
2839
+ ```
2840
+
2841
+ ### fixCodeSample
2842
+
2843
+ **Type:** function
2844
+ **File:** /Users/debmukherjee/autodocs/src/llm/index.ts
2845
+
2846
+ ```
2847
+ async function fixCodeSample(client: LLMClient, code: string, error: string, context: string, iteration: number = 1): Promise<string>
2848
+ ```
2849
+
2850
+ Use this to automatically repair broken code samples by sending them to an LLM with the error context and receiving a corrected version. Ideal for documentation pipelines, code generation workflows, or CI systems that validate and self-heal code examples.
2851
+
2852
+ ## Parameters
2853
+
2854
+ | Name | Type | Required | Description |
2855
+ |------|------|----------|-------------|
2856
+ | `client` | `LLMClient` | ✅ | An initialized LLM client instance used to generate the fix |
2857
+ | `code` | `string` | ✅ | The broken code sample that
2858
+
2859
+ **Example:**
2860
+ ```typescript
2861
+ // ── Inline types (do not import from autodocs) ──────────────────────────────
2862
+ interface LLMMessage {
2863
+ role: 'system' | 'user' | 'assistant'
2864
+ content: string
2865
+ }
2866
+
2867
+ interface LLMClient {
2868
+ complete(messages: LLMMessage[]): Promise<string>
2869
+ }
2870
+
2871
+ // ── Simulated LLM client (replace with your real client i
2872
+ ```
2873
+
2874
+ ### OpenAICompatibleClient
2875
+
2876
+ **Type:** class
2877
+ **File:** /Users/debmukherjee/autodocs/src/llm/openai-client.ts
2878
+
2879
+ ```
2880
+ class OpenAICompatibleClient implements LLMClient
2881
+ ```
2882
+
2883
+ Use this to connect to any OpenAI-compatible LLM provider — including OpenAI, DeepSeek, Ollama, OpenRouter, and Google Gemini — through a single unified client interface.
2884
+
2885
+ `OpenAICompatibleClient` normalizes provider differences (base URLs, auth headers, retry logic) so you can swap providers without changing your application code.
2886
+
2887
+ ## Constructor Config
2888
+
2889
+ | Name | Type | Required | Description |
2890
+ |------|------|----------|-------------|
2891
+ | `provider` | `LLMProvider` | ✅ | Provider identifier (e.g.
2892
+
2893
+ ### constructor
2894
+
2895
+ **Type:** method
2896
+ **File:** /Users/debmukherjee/autodocs/src/llm/openai-client.ts
2897
+
2898
+ ```
2899
+ constructor(config: LLMClientConfig)
2900
+ ```
2901
+
2902
+ Use this to create an LLM client that connects to any OpenAI-compatible API provider (OpenAI, Azure, Anthropic, local models, etc.) with automatic retry logic and provider-specific configuration.
2903
+
2904
+ ## Parameters
2905
+
2906
+ | Name | Type | Required | Description |
2907
+ |------|------|----------|-------------|
2908
+ | `config` | `LLMClientConfig` | ✅ | Configuration object for the LLM client |
2909
+ | `config.provider` | `LLMProvider` | ✅ | The LLM provider identifier (e.g., `'openai'`, `'anthropic'`, `'azure'`) |
2910
+ | `config.
2911
+
2912
+ **Example:**
2913
+ ```typescript
2914
+ // ── Inline types (no external imports needed) ──────────────────────────────
2915
+
2916
+ type LLMProvider = 'openai' | 'anthropic' | 'azure' | 'ollama' | string
2917
+
2918
+ interface LLMClientConfig {
2919
+ provider: LLMProvider
2920
+ model: string
2921
+ apiKey: string
2922
+ baseUrl?: string
2923
+ maxRetries?: number
2924
+ }
2925
+
2926
+ interface Completi
2927
+ ```
2928
+
2929
+ ### isConfigured
2930
+
2931
+ **Type:** method
2932
+ **File:** /Users/debmukherjee/autodocs/src/llm/openai-client.ts
2933
+
2934
+ ```
2935
+ isConfigured(): boolean
2936
+ ```
2937
+
2938
+ Use this to verify that an `OpenAICompatibleClient` instance is ready to make API calls before attempting completions.
2939
+
2940
+ This method acts as a readiness check — it always returns `true` because the underlying OpenAI SDK handles API key validation and configuration errors at request time rather than at initialization. Use it in guard clauses or health checks to conform to a standard client interface without worrying about pre-flight validation logic.
2941
+
2942
+ ### Returns
2943
+
2944
+ | Condition | Value |
2945
+ |----------
2946
+
2947
+ **Example:**
2948
+ ```typescript
2949
+ // Inline the minimal interface and class needed to demonstrate isConfigured()
2950
+ interface LLMClientConfig {
2951
+ apiKey: string
2952
+ model?: string
2953
+ baseURL?: string
2954
+ maxRetries?: number
2955
+ }
2956
+
2957
+ // Simulated OpenAICompatibleClient with isConfigured behavior
2958
+ class OpenAICompatibleClient {
2959
+ private apiKey: str
2960
+ ```
2961
+
2962
+ ### complete
2963
+
2964
+ **Type:** method
2965
+ **File:** /Users/debmukherjee/autodocs/src/llm/openai-client.ts
2966
+
2967
+ ```
2968
+ async complete(request: CompletionRequest): Promise<CompletionResponse>
2969
+ ```
2970
+
2971
+ Use this to send a chat completion request to any OpenAI-compatible API endpoint (OpenAI, Azure, Groq, Together AI, etc.) and receive a structured response with the generated text and token usage.
2972
+
2973
+ ## Parameters
2974
+
2975
+ | Name | Type | Required | Description |
2976
+ |------|------|----------|-------------|
2977
+ | `request` | `CompletionRequest` | Yes | The completion request object containing messages, model, and generation settings |
2978
+ | `request.messages` | `Array<{role: string, content: string}>` | Yes | Convers
2979
+
2980
+ **Example:**
2981
+ ```typescript
2982
+ import OpenAI from 'openai'
2983
+
2984
+ // --- Inline types (do not import from library) ---
2985
+ interface Message {
2986
+ role: 'system' | 'user' | 'assistant'
2987
+ content: string
2988
+ }
2989
+
2990
+ interface CompletionRequest {
2991
+ messages: Message[]
2992
+ model?: string
2993
+ temperature?: number
2994
+ maxTokens?: number
2995
+ systemPrompt?: string
2996
+
2997
+ ```
2998
+
2999
+ ### PluginManager
3000
+
3001
+ **Type:** class
3002
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3003
+
3004
+ ```
3005
+ class PluginManager
3006
+ ```
3007
+
3008
+ Use this to load, manage, and execute documentation plugins that transform source files into output during the autodocs build process.
3009
+
3010
+ `PluginManager` orchestrates the full plugin lifecycle — registering plugins, running them in sequence, and providing each plugin with shared context (paths, config, and a logger).
3011
+
3012
+ ## Constructor Parameters
3013
+
3014
+ | Name | Type | Required | Description |
3015
+ |------|------|----------|-------------|
3016
+ | `sourcePath` | `string` | Yes | Absolute or relative path to the source
3017
+
3018
+ **Example:**
3019
+ ```typescript
3020
+ // --- Inline types (no external imports needed) ---
3021
+
3022
+ type PluginContext = {
3023
+ sourcePath: string
3024
+ outputPath: string
3025
+ config: Record<string, unknown>
3026
+ logger: {
3027
+ info: (msg: string) => void
3028
+ warn: (msg: string) => void
3029
+ error: (msg: string) => void
3030
+ }
3031
+ }
3032
+
3033
+ type SkryptPlugin = {
3034
+ name: s
3035
+ ```
3036
+
3037
+ ### constructor
3038
+
3039
+ **Type:** method
3040
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3041
+
3042
+ ```
3043
+ constructor(sourcePath: string, outputPath: string, config: Record<string, unknown> = {})
3044
+ ```
3045
+
3046
+ Use this to initialize a plugin manager that coordinates documentation plugins across a source codebase, wiring together input/output paths and shared configuration before any plugins are registered or executed.
3047
+
3048
+ ## Parameters
3049
+
3050
+ | Name | Type | Required | Description |
3051
+ |------|------|----------|-------------|
3052
+ | `sourcePath` | `string` | ✅ Yes | Absolute or relative path to the source code directory to be processed |
3053
+ | `outputPath` | `string` | ✅ Yes | Absolute or relative path to the directory wh
3054
+
3055
+ **Example:**
3056
+ ```typescript
3057
+ // --- Inline types (mirroring the real autodocs internals) ---
3058
+ interface PluginContext {
3059
+ sourcePath: string
3060
+ outputPath: string
3061
+ config: Record<string, unknown>
3062
+ logger: {
3063
+ info: (msg: string) => void
3064
+ warn: (msg: string) => void
3065
+ error: (msg: string) => void
3066
+ }
3067
+ }
3068
+
3069
+ interface SkryptPl
3070
+ ```
3071
+
3072
+ ### loadPlugins
3073
+
3074
+ **Type:** method
3075
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3076
+
3077
+ ```
3078
+ async loadPlugins(configPath?: string): Promise<void>
3079
+ ```
3080
+
3081
+ Use this to initialize and load plugins into the `PluginManager` from a configuration file, enabling plugin-based extensibility in your application.
3082
+
3083
+ This method reads plugin definitions from a `skrypt.config.js` or `skrypt.config.ts` file (auto-discovered if no path is provided) and registers them with the manager. Call this once during application startup before executing any plugin-dependent logic.
3084
+
3085
+ ## Parameters
3086
+
3087
+ | Name | Type | Required | Description |
3088
+ |------|------|----------|------------
3089
+
3090
+ **Example:**
3091
+ ```typescript
3092
+ // Inline types to simulate PluginManager behavior
3093
+ type Plugin = {
3094
+ name: string
3095
+ execute: (input: string) => string
3096
+ }
3097
+
3098
+ type PluginConfig = {
3099
+ plugins: Plugin[]
3100
+ }
3101
+
3102
+ // Simulated PluginManager class (self-contained, no external imports)
3103
+ class PluginManager {
3104
+ private plugins: Map<string, Plugin> =
3105
+ ```
3106
+
3107
+ ### register
3108
+
3109
+ **Type:** method
3110
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3111
+
3112
+ ```
3113
+ register(plugin: SkryptPlugin): void
3114
+ ```
3115
+
3116
+ Use this to manually register a plugin with the `PluginManager`, adding it to the active plugin list so its hooks can be executed during the build or runtime lifecycle.
3117
+
3118
+ This is the direct registration path — useful when you have a plugin object already constructed in memory and don't need to load it from disk.
3119
+
3120
+ ### Parameters
3121
+
3122
+ | Name | Type | Required | Description |
3123
+ |------|------|----------|-------------|
3124
+ | `plugin` | `SkryptPlugin` | ✅ Yes | The plugin object to register. Must have at minimu
3125
+
3126
+ **Example:**
3127
+ ```typescript
3128
+ // --- Inline types (do not import from autodocs) ---
3129
+ type HookFn = (...args: unknown[]) => unknown | Promise<unknown>
3130
+
3131
+ interface SkryptPlugin {
3132
+ name: string
3133
+ version?: string
3134
+ onBuildStart?: HookFn
3135
+ onBuildEnd?: HookFn
3136
+ transform?: HookFn
3137
+ }
3138
+
3139
+ // --- Inline PluginManager implementation ---
3140
+ clas
3141
+ ```
3142
+
3143
+ ### runHook
3144
+
3145
+ **Type:** method
3146
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3147
+
3148
+ ```
3149
+ async runHook<T>(hook: keyof SkryptPlugin, ...args: unknown[]): Promise<T | undefined>
3150
+ ```
3151
+
3152
+ Use this to execute a named hook across all registered plugins in sequence, passing data through each plugin's implementation of that hook.
3153
+
3154
+ `runHook` iterates over every registered plugin, finds those that implement the specified hook method, and calls them in registration order. Each plugin receives the result of the previous plugin, enabling a pipeline/middleware pattern where plugins can transform data as it flows through.
3155
+
3156
+ ## Parameters
3157
+
3158
+ | Name | Type | Required | Description |
3159
+ |------|----
3160
+
3161
+ **Example:**
3162
+ ```typescript
3163
+ // --- Inline types (do not import from autodocs) ---
3164
+ interface SkryptPlugin {
3165
+ name: string
3166
+ version?: string
3167
+ beforeCompile?: (source: string) => Promise<string> | string
3168
+ afterCompile?: (output: string) => Promise<string> | string
3169
+ onError?: (error: Error) => Promise<void> | void
3170
+ }
3171
+
3172
+ // --- I
3173
+ ```
3174
+
3175
+ ### onInit
3176
+
3177
+ **Type:** method
3178
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3179
+
3180
+ ```
3181
+ async onInit(): Promise<void>
3182
+ ```
3183
+
3184
+ Use this to trigger the initialization lifecycle hook across all registered plugins in a `PluginManager` instance. Call this once after all plugins have been registered and before any scanning or processing begins.
3185
+
3186
+ This method delegates to the internal `runHook('onInit')` mechanism, ensuring every plugin's `onInit` handler is executed in sequence.
3187
+
3188
+ ## Parameters
3189
+
3190
+ _None_
3191
+
3192
+ ## Returns
3193
+
3194
+ | Type | Description |
3195
+ |------|-------------|
3196
+ | `Promise<void>` | Resolves when all plugin `onInit` hooks have co
3197
+
3198
+ **Example:**
3199
+ ```typescript
3200
+ // Inline types to simulate the PluginManager lifecycle
3201
+ type HookName = 'onInit' | 'onBeforeScan' | 'onAfterScan'
3202
+
3203
+ type Plugin = {
3204
+ name: string
3205
+ onInit?: () => Promise<void>
3206
+ onBeforeScan?: () => Promise<void>
3207
+ }
3208
+
3209
+ // Simulated PluginManager class (self-contained, no external imports)
3210
+ class Plugin
3211
+ ```
3212
+
3213
+ ### onBeforeScan
3214
+
3215
+ **Type:** method
3216
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3217
+
3218
+ ```
3219
+ async onBeforeScan(): Promise<void>
3220
+ ```
3221
+
3222
+ Use this to trigger all registered plugins' pre-scan lifecycle hooks before a documentation scan begins. This allows plugins to perform setup tasks, validate configurations, or prepare resources before any files are processed.
3223
+
3224
+ ## Parameters
3225
+
3226
+ This method takes no parameters.
3227
+
3228
+ ## Returns
3229
+
3230
+ | Type | Description |
3231
+ |------|-------------|
3232
+ | `Promise<void>` | Resolves when all registered plugins have completed their `onBeforeScan` hooks. Rejects if any plugin hook throws an error. |
3233
+
3234
+ ## When to Call
3235
+
3236
+ C
3237
+
3238
+ **Example:**
3239
+ ```typescript
3240
+ // Inline types to simulate the PluginManager behavior
3241
+ type HookName = 'onInit' | 'onBeforeScan' | 'onAfterScan'
3242
+
3243
+ interface Plugin {
3244
+ name: string
3245
+ onInit?: () => Promise<void>
3246
+ onBeforeScan?: () => Promise<void>
3247
+ onAfterScan?: <T>(elements: T[]) => Promise<T[]>
3248
+ }
3249
+
3250
+ // Simulated PluginManager cla
3251
+ ```
3252
+
3253
+ ### onAfterScan
3254
+
3255
+ **Type:** method
3256
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3257
+
3258
+ ```
3259
+ async onAfterScan<T>(elements: T[]): Promise<T[]>
3260
+ ```
3261
+
3262
+ Use this to run all registered plugins' `onAfterScan` hooks against a list of scanned elements, allowing plugins to filter, transform, or enrich the results before further processing.
3263
+
3264
+ This is called automatically by the `PluginManager` after a scan completes. Each plugin that implements `onAfterScan` gets a chance to modify the elements array in sequence. If no plugin modifies the elements, the original array is returned unchanged.
3265
+
3266
+ ## Parameters
3267
+
3268
+ | Name | Type | Required | Description |
3269
+ |-----
3270
+
3271
+ **Example:**
3272
+ ```typescript
3273
+ // Inline types to simulate PluginManager behavior
3274
+ type Plugin = {
3275
+ name: string
3276
+ onAfterScan?: <T>(elements: T[]) => Promise<T[]>
3277
+ }
3278
+
3279
+ type ScannedFile = {
3280
+ path: string
3281
+ type: string
3282
+ exported: boolean
3283
+ }
3284
+
3285
+ // Simulate the PluginManager class
3286
+ class PluginManager {
3287
+ private plugins: Plugin[] = []
3288
+ ```
3289
+
3290
+ ### onBeforeGenerate
3291
+
3292
+ **Type:** method
3293
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3294
+
3295
+ ```
3296
+ async onBeforeGenerate<T>(elements: T[]): Promise<T[]>
3297
+ ```
3298
+
3299
+ Use this to run all registered plugins' `onBeforeGenerate` hooks against a collection of elements before documentation generation begins. This is the ideal interception point for filtering, transforming, sorting, or enriching your elements (e.g., parsed AST nodes, function signatures, class definitions) before they are handed off to the doc generator.
3300
+
3301
+ If no plugin hook modifies the elements, the original array is returned unchanged.
3302
+
3303
+ ## Parameters
3304
+
3305
+ | Name | Type | Required | Description |
3306
+ |----
3307
+
3308
+ **Example:**
3309
+ ```typescript
3310
+ // Inline types to simulate the PluginManager behavior
3311
+ type Hook<T> = (elements: T[]) => Promise<T[] | null | undefined>
3312
+
3313
+ interface Plugin {
3314
+ onBeforeGenerate?: <T>(elements: T[]) => Promise<T[]>
3315
+ }
3316
+
3317
+ // Simulated PluginManager with onBeforeGenerate support
3318
+ class PluginManager {
3319
+ private plugins: Pl
3320
+ ```
3321
+
3322
+ ### onAfterGenerate
3323
+
3324
+ **Type:** method
3325
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3326
+
3327
+ ```
3328
+ async onAfterGenerate<T>(docs: T[]): Promise<T[]>
3329
+ ```
3330
+
3331
+ Use this to run all registered plugins' `onAfterGenerate` hooks against a collection of generated documentation objects, allowing plugins to transform, filter, enrich, or reorder docs before they are written to disk.
3332
+
3333
+ This is the final transformation stage in the generation pipeline — ideal for plugins that need to post-process docs (e.g., injecting metadata, removing internal-only entries, sorting output).
3334
+
3335
+ ## Parameters
3336
+
3337
+ | Name | Type | Required | Description |
3338
+ |------|------|----------|------
3339
+
3340
+ **Example:**
3341
+ ```typescript
3342
+ // Inline types to simulate the PluginManager behavior
3343
+ type Hook<T> = (data: T) => Promise<T> | T
3344
+
3345
+ interface Plugin {
3346
+ name: string
3347
+ onAfterGenerate?: Hook<any[]>
3348
+ }
3349
+
3350
+ interface DocEntry {
3351
+ id: string
3352
+ title: string
3353
+ content: string
3354
+ internal?: boolean
3355
+ }
3356
+
3357
+ // Minimal self-contained PluginManager
3358
+ ```
3359
+
3360
+ ### onBeforeWrite
3361
+
3362
+ **Type:** method
3363
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3364
+
3365
+ ```
3366
+ async onBeforeWrite<T>(docs: T[]): Promise<T[]>
3367
+ ```
3368
+
3369
+ Use this to run all registered plugins' `onBeforeWrite` hooks against your generated docs array, allowing plugins to transform, filter, or enrich documents just before they are written to disk.
3370
+
3371
+ This is the last interception point before output is committed — ideal for plugins that need to inject metadata, reorder entries, strip internal fields, or validate documents.
3372
+
3373
+ ## Parameters
3374
+
3375
+ | Name | Type | Required | Description |
3376
+ |------|------|----------|-------------|
3377
+ | `docs` | `T[]` | Yes | Array
3378
+
3379
+ **Example:**
3380
+ ```typescript
3381
+ // Inline types to simulate the PluginManager behavior
3382
+ type Plugin<T> = {
3383
+ onBeforeWrite?: (docs: T[]) => Promise<T[]>
3384
+ }
3385
+
3386
+ type DocEntry = {
3387
+ name: string
3388
+ content: string
3389
+ metadata?: Record<string, unknown>
3390
+ }
3391
+
3392
+ // Simulated PluginManager with onBeforeWrite support
3393
+ class PluginManager<T> {
3394
+ priva
3395
+ ```
3396
+
3397
+ ### onAfterWrite
3398
+
3399
+ **Type:** method
3400
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3401
+
3402
+ ```
3403
+ async onAfterWrite(): Promise<void>
3404
+ ```
3405
+
3406
+ Use this to trigger all registered plugin hooks after documentation has been written to disk — ideal for post-write tasks like cache invalidation, notifications, or cleanup.
3407
+
3408
+ `onAfterWrite` runs through every loaded plugin's `onAfterWrite` hook in sequence. It resolves when all hooks complete and does not return a value. If no plugins define this hook, it resolves immediately.
3409
+
3410
+ ### Parameters
3411
+
3412
+ This method takes no parameters.
3413
+
3414
+ ### Returns
3415
+
3416
+ | Type | Description |
3417
+ |------|-------------|
3418
+ | `Promise
3419
+
3420
+ **Example:**
3421
+ ```typescript
3422
+ // Inline types to keep example self-contained
3423
+ type Hook = (...args: unknown[]) => Promise<unknown> | unknown
3424
+
3425
+ interface Plugin {
3426
+ name: string
3427
+ onAfterWrite?: () => Promise<void> | void
3428
+ onBeforeWrite?: <T>(docs: T[]) => Promise<T[]> | T[]
3429
+ }
3430
+
3431
+ // Simulated PluginManager implementation
3432
+ class Plugi
3433
+ ```
3434
+
3435
+ ### transformContent
3436
+
3437
+ **Type:** method
3438
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3439
+
3440
+ ```
3441
+ async transformContent(content: string, filePath: string): Promise<string>
3442
+ ```
3443
+
3444
+ Use this to pipe file content through a chain of registered plugins, each of which can modify the content before it's written to disk. Ideal for applying transformations like syntax highlighting, markdown processing, code formatting, or custom replacements across your documentation pipeline.
3445
+
3446
+ Each plugin in the manager that implements `transformContent` is called in sequence — the output of one becomes the input of the next.
3447
+
3448
+ ## Parameters
3449
+
3450
+ | Name | Type | Required | Description |
3451
+ |------|------
3452
+
3453
+ **Example:**
3454
+ ```typescript
3455
+ // Inline types — no external imports needed
3456
+ type TransformPlugin = {
3457
+ name: string
3458
+ transformContent?: (content: string, filePath: string) => Promise<string>
3459
+ }
3460
+
3461
+ // Simulated PluginManager class
3462
+ class PluginManager {
3463
+ private plugins: TransformPlugin[]
3464
+
3465
+ constructor(plugins: TransformPlugin[]) {
3466
+ ```
3467
+
3468
+ ### definePlugin
3469
+
3470
+ **Type:** function
3471
+ **File:** /Users/debmukherjee/autodocs/src/plugins/index.ts
3472
+
3473
+ ```
3474
+ function definePlugin(plugin: SkryptPlugin): SkryptPlugin
3475
+ ```
3476
+
3477
+ Use this to define a typed plugin configuration object for the Skrypt plugin system with full type safety and IDE autocompletion.
3478
+
3479
+ This is an identity function that acts as a **type helper** — it takes your plugin definition and returns it unchanged, but ensures your object conforms to the `SkryptPlugin` interface at compile time. Think of it as the Skrypt equivalent of Vue's `defineComponent` or Vite's `defineConfig`.
3480
+
3481
+ ## Parameters
3482
+
3483
+ | Name | Type | Required | Description |
3484
+ |------|------|-----
3485
+
3486
+ **Example:**
3487
+ ```typescript
3488
+ // Inline the SkryptPlugin type (do not import from autodocs)
3489
+ type PluginHookContext = {
3490
+ cwd: string
3491
+ config: Record<string, unknown>
3492
+ }
3493
+
3494
+ type SkryptPlugin = {
3495
+ name: string
3496
+ version?: string
3497
+ description?: string
3498
+ setup?: (context: PluginHookContext) => void | Promise<void>
3499
+ teardown?: () =>
3500
+ ```
3501
+
3502
+ ### classifyElement
3503
+
3504
+ **Type:** function
3505
+ **File:** /Users/debmukherjee/autodocs/src/scanner/content-type.ts
3506
+
3507
+ ```
3508
+ function classifyElement(element: APIElement): ContentClassification
3509
+ ```
3510
+
3511
+ Use this to determine what type of documentation an API element needs — whether it's best suited for API reference docs, a guide, or a tutorial.
3512
+
3513
+ Given an `APIElement`, `classifyElement` analyzes its characteristics and returns a `ContentClassification` indicating the recommended documentation type and the reasoning behind that recommendation. Use this when auto-generating or organizing documentation to ensure each element gets the right treatment.
3514
+
3515
+ ## Parameters
3516
+
3517
+ | Name | Type | Required | Desc
3518
+
3519
+ **Example:**
3520
+ ```typescript
3521
+ // ── Inline types (no external imports needed) ──────────────────────────────
3522
+
3523
+ type APIElementKind = 'function' | 'class' | 'interface' | 'type' | 'variable'
3524
+
3525
+ interface APIElement {
3526
+ name: string
3527
+ kind: APIElementKind
3528
+ parameters?: { name: string; type: string; optional?: boolean }[]
3529
+ returnTyp
3530
+ ```
3531
+
3532
+ ### classifyElements
3533
+
3534
+ **Type:** function
3535
+ **File:** /Users/debmukherjee/autodocs/src/scanner/content-type.ts
3536
+
3537
+ ```
3538
+ function classifyElements(elements: APIElement[]): Map<ContentType, APIElement[]>
3539
+ ```
3540
+
3541
+ Use this to sort a mixed list of documentation elements into typed groups — API references, guides, tutorials, and overviews — in a single pass.
3542
+
3543
+ Instead of manually filtering arrays for each content type, `classifyElements` returns a `Map` keyed by content type so you can immediately access any group by name.
3544
+
3545
+ ### Parameters
3546
+
3547
+ | Name | Type | Required | Description |
3548
+ |------|------|----------|-------------|
3549
+ | `elements` | `APIElement[]` | ✅ | Array of documentation elements to classify. Each ele
3550
+
3551
+ **Example:**
3552
+ ```typescript
3553
+ // --- Inline types (do not import from autodocs) ---
3554
+ type ContentType = 'api' | 'guide' | 'tutorial' | 'overview'
3555
+
3556
+ interface APIElement {
3557
+ id: string
3558
+ title: string
3559
+ type: ContentType
3560
+ content: string
3561
+ }
3562
+
3563
+ // --- Inline implementation matching autodocs behavior ---
3564
+ function classifyElements(eleme
3565
+ ```
3566
+
3567
+ ### getRecommendedStructure
3568
+
3569
+ **Type:** function
3570
+ **File:** /Users/debmukherjee/autodocs/src/scanner/content-type.ts
3571
+
3572
+ ```
3573
+ function getRecommendedStructure(elements: APIElement[]): {
3574
+ sections: { name: string; type: ContentType; elements: APIElement[] }[]
3575
+ stats: { api: number; guide: number; tutorial: number; overview: number }
3576
+ }
3577
+ ```
3578
+
3579
+ Use this to automatically organize a mixed set of API elements into a recommended documentation structure — grouping them into logical sections (API reference, guides, tutorials, overviews) and getting a count breakdown by content type.
3580
+
3581
+ This is useful when you have a large set of parsed API elements and need to determine how to structure your documentation site or output files without manually categorizing each element.
3582
+
3583
+ ## Parameters
3584
+
3585
+ | Name | Type | Required | Description |
3586
+ |------|------|---
3587
+
3588
+ **Example:**
3589
+ ```typescript
3590
+ // ---- Inline types (do not import from autodocs) ----
3591
+ type ContentType = 'api' | 'guide' | 'tutorial' | 'overview'
3592
+
3593
+ type APIElement = {
3594
+ name: string
3595
+ kind: 'function' | 'class' | 'interface' | 'type' | 'variable' | 'module'
3596
+ description?: string
3597
+ tags?: string[]
3598
+ }
3599
+
3600
+ type Section = {
3601
+ name: st
3602
+ ```
3603
+
3604
+ ### getPromptForContentType
3605
+
3606
+ **Type:** function
3607
+ **File:** /Users/debmukherjee/autodocs/src/scanner/content-type.ts
3608
+
3609
+ ```
3610
+ function getPromptForContentType(type: ContentType): string
3611
+ ```
3612
+
3613
+ Use this to get the appropriate documentation generation prompt string for a given content type — so you can feed the right instructions into an AI model or documentation pipeline based on what you're documenting.
3614
+
3615
+ This function maps a `ContentType` value to a tailored prompt string that instructs a documentation generator on what to include (e.g., parameter types for APIs, usage examples for components, etc.).
3616
+
3617
+ ## Parameters
3618
+
3619
+ | Name | Type | Required | Description |
3620
+ |------|------|----------|--
3621
+
3622
+ **Example:**
3623
+ ```typescript
3624
+ // Inline the ContentType definition — no external imports needed
3625
+ type ContentType = 'api' | 'component' | 'guide' | 'utility'
3626
+
3627
+ // Inline a representative implementation of getPromptForContentType
3628
+ function getPromptForContentType(type: ContentType): string {
3629
+ switch (type) {
3630
+ case 'api':
3631
+ r
3632
+ ```
3633
+
3634
+ ### GoScanner
3635
+
3636
+ **Type:** class
3637
+ **File:** /Users/debmukherjee/autodocs/src/scanner/go.ts
3638
+
3639
+ ```
3640
+ class GoScanner implements Scanner
3641
+ ```
3642
+
3643
+ Use this to scan Go source files and extract API elements — functions, methods, structs, and interfaces — for automated documentation generation pipelines.
3644
+
3645
+ `GoScanner` implements the `Scanner` interface and targets `.go` files, automatically skipping test files (`_test.go`).
3646
+
3647
+ ## Methods
3648
+
3649
+ ### `canHandle(filePath: string): boolean`
3650
+ Returns `true` if the file path ends in `.go` and is not a test file. Use this to check compatibility before scanning.
3651
+
3652
+ ### `scanFile(filePath: string): Promise<ScanRe
3653
+
3654
+ ### canHandle
3655
+
3656
+ **Type:** method
3657
+ **File:** /Users/debmukherjee/autodocs/src/scanner/go.ts
3658
+
3659
+ ```
3660
+ canHandle(filePath: string): boolean
3661
+ ```
3662
+
3663
+ Use this to check whether a Go source file should be processed by the `GoScanner` — it returns `true` for `.go` files that are **not** test files (`_test.go`).
3664
+
3665
+ This is the gating method called before scanning a file for functions, methods, types, and interfaces. It prevents test files from being included in documentation output.
3666
+
3667
+ ### Parameters
3668
+
3669
+ | Name | Type | Required | Description |
3670
+ |------|------|----------|-------------|
3671
+ | `filePath` | `string` | ✅ | Absolute or relative path to the file b
3672
+
3673
+ **Example:**
3674
+ ```typescript
3675
+ // Inline implementation matching GoScanner.canHandle behavior
3676
+ class GoScanner {
3677
+ languages = ['go']
3678
+
3679
+ canHandle(filePath: string): boolean {
3680
+ return /\.go$/.test(filePath) && !filePath.includes('_test.go')
3681
+ }
3682
+ }
3683
+
3684
+ const scanner = new GoScanner()
3685
+
3686
+ const testCases: Array<{ path: string; expected:
3687
+ ```
3688
+
3689
+ ### scanFile
3690
+
3691
+ **Type:** method
3692
+ **File:** /Users/debmukherjee/autodocs/src/scanner/go.ts
3693
+
3694
+ ```
3695
+ async scanFile(filePath: string): Promise<ScanResult>
3696
+ ```
3697
+
3698
+ Use this to extract API elements from a Go source file, returning all discovered functions, types, and parameters in a structured result.
3699
+
3700
+ `scanFile` reads and parses a `.go` file (excluding test files), identifying exported API elements and collecting any parse errors encountered during scanning.
3701
+
3702
+ > **Note:** Only handles non-test Go files (`.go` extension, not `_test.go`). Use `canHandle(filePath)` to verify compatibility before calling.
3703
+
3704
+ ## Parameters
3705
+
3706
+ | Name | Type | Required | Description |
3707
+
3708
+ **Example:**
3709
+ ```typescript
3710
+ import { writeFileSync, unlinkSync } from 'fs'
3711
+ import { promisify } from 'util'
3712
+
3713
+ // --- Inline types (mirrors the real library's types) ---
3714
+ type Parameter = {
3715
+ name: string
3716
+ type: string
3717
+ required?: boolean
3718
+ }
3719
+
3720
+ type APIElement = {
3721
+ name: string
3722
+ kind: 'function' | 'type' | 'method'
3723
+ parameters?
3724
+ ```
3725
+
3726
+ ### scanDirectory
3727
+
3728
+ **Type:** function
3729
+ **File:** /Users/debmukherjee/autodocs/src/scanner/index.ts
3730
+
3731
+ ```
3732
+ async function scanDirectory(dir: string, options: ScanOptions = {}): Promise<ScanAllResult>
3733
+ ```
3734
+
3735
+ Use this to recursively scan a directory (or single file) for all API elements — functions, classes, types, and exports — across multiple languages including Python, TypeScript, JavaScript, Go, and Rust.
3736
+
3737
+ This is the primary entry point for automated documentation generation pipelines. Point it at a project root and get back a structured inventory of every public API element found.
3738
+
3739
+ ## Parameters
3740
+
3741
+ | Name | Type | Required | Description |
3742
+ |------|------|----------|-------------|
3743
+ | `dir` | `string
3744
+
3745
+ ### scanFile
3746
+
3747
+ **Type:** function
3748
+ **File:** /Users/debmukherjee/autodocs/src/scanner/index.ts
3749
+
3750
+ ```
3751
+ async function scanFile(filePath: string): Promise<ScanResult>
3752
+ ```
3753
+
3754
+ Use this to extract structured metadata from a single source file — functions, classes, types, and other symbols — without scanning an entire directory.
3755
+
3756
+ `scanFile` inspects a file at the given path, selects the appropriate language scanner (TypeScript, JavaScript, Python, etc.), and returns a structured `ScanResult` containing all discovered symbols and language information.
3757
+
3758
+ ## Parameters
3759
+
3760
+ | Name | Type | Required | Description |
3761
+ |------|------|----------|-------------|
3762
+ | `filePath` | `string`
3763
+
3764
+ **Example:**
3765
+ ```typescript
3766
+ // Inline types matching the autodocs ScanResult shape
3767
+ type SymbolKind = 'function' | 'class' | 'type' | 'interface' | 'variable'
3768
+
3769
+ interface DocSymbol {
3770
+ name: string
3771
+ kind: SymbolKind
3772
+ line: number
3773
+ docstring?: string
3774
+ signature?: string
3775
+ }
3776
+
3777
+ interface ScanResult {
3778
+ filePath: string
3779
+ language:
3780
+ ```
3781
+
3782
+ ### PythonScanner
3783
+
3784
+ **Type:** class
3785
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python.ts
3786
+
3787
+ ```
3788
+ class PythonScanner implements Scanner
3789
+ ```
3790
+
3791
+ Use this to scan Python source files and extract structured metadata (functions, classes, imports, etc.) by delegating parsing to a Python3 subprocess.
3792
+
3793
+ `PythonScanner` implements the `Scanner` interface and is the go-to handler for any `.py` file in an autodocs pipeline. It spawns a `python3` process running an internal parser script, then resolves a `ScanResult` with the extracted code structure.
3794
+
3795
+ ## Properties
3796
+
3797
+ | Property | Type | Description |
3798
+ |---|---|---|
3799
+ | `languages` | `string[]` | Alway
3800
+
3801
+ **Example:**
3802
+ ```typescript
3803
+ import { spawn } from 'child_process'
3804
+ import { writeFileSync, unlinkSync } from 'fs'
3805
+ import { join } from 'path'
3806
+ import { tmpdir } from 'os'
3807
+
3808
+ // --- Inline types (mirrors autodocs Scanner interface) ---
3809
+ interface ScanResult {
3810
+ filePath: string
3811
+ language: string
3812
+ symbols?: Symbol[]
3813
+ error?: strin
3814
+ ```
3815
+
3816
+ ### canHandle
3817
+
3818
+ **Type:** method
3819
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python.ts
3820
+
3821
+ ```
3822
+ canHandle(filePath: string): boolean
3823
+ ```
3824
+
3825
+ Use this to quickly check whether a file should be processed by the Python scanner before attempting to parse or analyze it.
3826
+
3827
+ `canHandle` inspects a file path and returns `true` if it ends with `.py`, allowing you to gate Python-specific scanning logic without wasting resources on unsupported file types.
3828
+
3829
+ ### Parameters
3830
+
3831
+ | Name | Type | Required | Description |
3832
+ |------|------|----------|-------------|
3833
+ | `filePath` | `string` | ✅ | The path or filename to check for Python file extension |
3834
+
3835
+ ### Re
3836
+
3837
+ **Example:**
3838
+ ```typescript
3839
+ // Inline implementation matching PythonScanner behavior
3840
+ class PythonScanner {
3841
+ languages = ['python']
3842
+
3843
+ canHandle(filePath: string): boolean {
3844
+ return filePath.endsWith('.py')
3845
+ }
3846
+ }
3847
+
3848
+ const scanner = new PythonScanner()
3849
+
3850
+ const testFiles = [
3851
+ '/project/src/main.py',
3852
+ '/project/src/utils.py',
3853
+
3854
+ ```
3855
+
3856
+ ### scanFile
3857
+
3858
+ **Type:** method
3859
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python.ts
3860
+
3861
+ ```
3862
+ async scanFile(filePath: string): Promise<ScanResult>
3863
+ ```
3864
+
3865
+ Use this to scan a Python source file and extract structured metadata — functions, classes, imports, and other code elements — for documentation generation or static analysis pipelines.
3866
+
3867
+ `scanFile` spawns a Python3 parser subprocess against the target `.py` file and resolves with a structured `ScanResult` object. It is a method on `PythonScanner`, which only handles files ending in `.py` (check with `canHandle` before calling).
3868
+
3869
+ ## Parameters
3870
+
3871
+ | Name | Type | Required | Description |
3872
+ |------|---
3873
+
3874
+ **Example:**
3875
+ ```typescript
3876
+ import { spawn } from 'child_process'
3877
+ import { resolve } from 'path'
3878
+ import { writeFileSync, unlinkSync } from 'fs'
3879
+
3880
+ // --- Inline types (mirrors the real ScanResult shape) ---
3881
+ interface ScannedFunction {
3882
+ name: string
3883
+ lineStart: number
3884
+ lineEnd: number
3885
+ docstring?: string
3886
+ }
3887
+
3888
+ interface ScannedC
3889
+ ```
3890
+
3891
+ ### get_docstring
3892
+
3893
+ **Type:** function
3894
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
3895
+
3896
+ ```
3897
+ def get_docstring(node: ast.AST) -> str | None
3898
+ ```
3899
+
3900
+ Use this to extract the docstring from any Python AST node (functions, classes, modules) when parsing or analyzing Python source code programmatically.
3901
+
3902
+ Returns the docstring as a `str` if one is present on the node, or `None` if no docstring exists.
3903
+
3904
+ ## Parameters
3905
+
3906
+ | Name | Type | Required | Description |
3907
+ |------|------|----------|-------------|
3908
+ | node | `ast.AST` | ✅ Yes | Any parsed AST node — typically a `Module`, `FunctionDef`, `AsyncFunctionDef`, or `ClassDef` node |
3909
+
3910
+ ## Returns
3911
+
3912
+ | Value |
3913
+
3914
+ **Example:**
3915
+ ```python
3916
+ import ast
3917
+
3918
+ # Inline implementation of get_docstring
3919
+ def get_docstring(node: ast.AST) -> str | None:
3920
+ """Extract docstring from a node if present."""
3921
+ if not isinstance(node, (ast.Module, ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
3922
+ return None
3923
+ if not node.body:
3924
+ r
3925
+ ```
3926
+
3927
+ ### get_type_annotation
3928
+
3929
+ **Type:** function
3930
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
3931
+
3932
+ ```
3933
+ def get_type_annotation(annotation: ast.AST | None) -> str | None
3934
+ ```
3935
+
3936
+ Use this to convert a Python AST type annotation node into its human-readable string representation — ideal for documentation generators, code analyzers, or any tool that needs to display type hints as readable text.
3937
+
3938
+ Returns `None` if the annotation is `None` or cannot be resolved. Returns a string like `"str"`, `"int"`, `"List[str]"`, or `"Optional[int]"` for valid annotations.
3939
+
3940
+ ## Parameters
3941
+
3942
+ | Name | Type | Required | Description |
3943
+ |------|------|----------|-------------|
3944
+ | `annotation` | `a
3945
+
3946
+ **Example:**
3947
+ ```python
3948
+ import ast
3949
+
3950
+ # Inline implementation of get_type_annotation
3951
+ def get_type_annotation(annotation: ast.AST | None) -> str | None:
3952
+ """Convert type annotation AST to string."""
3953
+ if annotation is None:
3954
+ return None
3955
+ try:
3956
+ return ast.unparse(annotation)
3957
+ except Exception:
3958
+
3959
+ ```
3960
+
3961
+ ### get_default_value
3962
+
3963
+ **Type:** function
3964
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
3965
+
3966
+ ```
3967
+ def get_default_value(default: ast.AST | None) -> str | None
3968
+ ```
3969
+
3970
+ Use this to extract a human-readable string representation of a Python function parameter's default value from its AST node — perfect for documentation generators, code analyzers, or introspection tools that need to display default values as they appear in source code.
3971
+
3972
+ Returns `None` if no default exists (i.e., the parameter has no default value), or a string like `"42"`, `"'hello'"`, or `"None"` when a default is present.
3973
+
3974
+ ## Parameters
3975
+
3976
+ | Name | Type | Required | Description |
3977
+ |------|------|
3978
+
3979
+ **Example:**
3980
+ ```python
3981
+ import ast
3982
+
3983
+ def get_default_value(default: ast.AST | None) -> str | None:
3984
+ """Convert default value AST to string."""
3985
+ if default is None:
3986
+ return None
3987
+ return ast.unparse(default)
3988
+
3989
+
3990
+ def extract_param_defaults(source_code: str) -> dict:
3991
+ """Parse a function and extract parameter n
3992
+ ```
3993
+
3994
+ ### extract_parameters
3995
+
3996
+ **Type:** function
3997
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
3998
+
3999
+ ```
4000
+ def extract_parameters(args: ast.arguments) -> list[dict[str, Any]]
4001
+ ```
4002
+
4003
+ Use this to convert Python AST function arguments into a structured list of parameter metadata — ideal for building documentation generators, code analyzers, or introspection tools.
4004
+
4005
+ Given an `ast.arguments` object (from parsing a Python function), this returns a list of dictionaries, each describing one parameter: its name, type annotation (if any), and default value (if any).
4006
+
4007
+ ## Parameters
4008
+
4009
+ | Name | Type | Required | Description |
4010
+ |------|------|----------|-------------|
4011
+ | `args` | `ast.argum
4012
+
4013
+ **Example:**
4014
+ ```python
4015
+ import ast
4016
+ from typing import Any
4017
+
4018
+ # ── Inline implementation of extract_parameters ──────────────────────────────
4019
+
4020
+ def extract_parameters(args: ast.arguments) -> list[dict[str, Any]]:
4021
+ """Extract parameters from function arguments."""
4022
+ params: list[dict[str, Any]] = []
4023
+
4024
+ all_args = args.po
4025
+ ```
4026
+
4027
+ ### build_signature
4028
+
4029
+ **Type:** function
4030
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
4031
+
4032
+ ```
4033
+ def build_signature(name: str, args: ast.arguments, returns: ast.AST | None, is_async: bool) -> str
4034
+ ```
4035
+
4036
+ Use this to reconstruct a human-readable function signature string from its parsed AST components — useful for code analysis tools, documentation generators, or any system that needs to display or compare function signatures without executing the code.
4037
+
4038
+ ## Parameters
4039
+
4040
+ | Name | Type | Required | Description |
4041
+ |------|------|----------|-------------|
4042
+ | `name` | `str` | ✅ | The function name to include in the signature |
4043
+ | `args` | `ast.arguments` | ✅ | The parsed argument node from the AST, contai
4044
+
4045
+ **Example:**
4046
+ ```python
4047
+ import ast
4048
+
4049
+ def build_signature(name: str, args: ast.arguments, returns, is_async: bool) -> str:
4050
+ """Reconstruct a function signature string from AST components."""
4051
+ parts = []
4052
+
4053
+ # Build each argument with optional annotation and default
4054
+ num_args = len(args.args)
4055
+ num_defaults = len(
4056
+ ```
4057
+
4058
+ ### extract_function
4059
+
4060
+ **Type:** function
4061
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
4062
+
4063
+ ```
4064
+ def extract_function(node: ast.FunctionDef | ast.AsyncFunctionDef, file_path: str, parent_class: str | None) -> dict[str, Any]
4065
+ ```
4066
+
4067
+ Use this to extract structured metadata from a Python function or method AST node — including its name, arguments, return type, decorators, and source location — for use in code analysis, documentation generation, or static analysis tooling.
4068
+
4069
+ Given an AST node representing a function or async function, this returns a dictionary containing all key metadata about that function, ready for serialization or further processing.
4070
+
4071
+ ## Parameters
4072
+
4073
+ | Name | Type | Required | Description |
4074
+ |------|------|--
4075
+
4076
+ **Example:**
4077
+ ```python
4078
+ import ast
4079
+ from typing import Any
4080
+
4081
+ # Inline implementation of extract_function
4082
+ def extract_function(
4083
+ node: ast.FunctionDef | ast.AsyncFunctionDef,
4084
+ file_path: str,
4085
+ parent_class: str | None = None
4086
+ ) -> dict[str, Any]:
4087
+ """Extract structured metadata from a function or method AST node.""
4088
+ ```
4089
+
4090
+ ### extract_class
4091
+
4092
+ **Type:** function
4093
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
4094
+
4095
+ ```
4096
+ def extract_class(node: ast.ClassDef, file_path: str) -> list[dict[str, Any]]
4097
+ ```
4098
+
4099
+ Use this to parse a Python class AST node into a structured list of dictionaries containing the class definition and all its methods — ideal for building code analysis tools, documentation generators, or code indexing pipelines.
4100
+
4101
+ Each dictionary in the returned list represents either the class itself or one of its methods, with metadata like name, docstring, line numbers, and source file path.
4102
+
4103
+ ## Parameters
4104
+
4105
+ | Name | Type | Required | Description |
4106
+ |------|------|----------|-------------|
4107
+ | `no
4108
+
4109
+ **Example:**
4110
+ ```python
4111
+ import ast
4112
+ from typing import Any
4113
+
4114
+ # Inline implementation of extract_class for a self-contained example
4115
+ def extract_class(node: ast.ClassDef, file_path: str) -> list[dict[str, Any]]:
4116
+ """Extract a class and its methods into structured dicts."""
4117
+ results = []
4118
+
4119
+ # Extract class-level entry
4120
+
4121
+ ```
4122
+
4123
+ ### scan_file
4124
+
4125
+ **Type:** function
4126
+ **File:** /Users/debmukherjee/autodocs/src/scanner/python_parser.py
4127
+
4128
+ ```
4129
+ def scan_file(file_path: str) -> dict[str, Any]
4130
+ ```
4131
+
4132
+ Use this to extract all API elements from a Python source file — functions, classes, methods, imports, and metadata — in a single structured dictionary.
4133
+
4134
+ Ideal for building documentation generators, code analysis tools, static analyzers, or any tooling that needs to introspect a Python file programmatically.
4135
+
4136
+ ## Parameters
4137
+
4138
+ | Name | Type | Required | Description |
4139
+ |------|------|----------|-------------|
4140
+ | `file_path` | `str` | ✅ Yes | Absolute or relative path to the `.py` file to scan |
4141
+
4142
+ ## Re
4143
+
4144
+ **Example:**
4145
+ ```python
4146
+ import ast
4147
+ import os
4148
+ from typing import Any
4149
+
4150
+ # Inline implementation of scan_file
4151
+ def scan_file(file_path: str) -> dict[str, Any]:
4152
+ """Scan a Python file and extract all API elements."""
4153
+ result: dict[str, Any] = {
4154
+ "file_path": file_path,
4155
+ "functions": [],
4156
+ "classes": [],
4157
+ ```
4158
+
4159
+ ### RustScanner
4160
+
4161
+ **Type:** class
4162
+ **File:** /Users/debmukherjee/autodocs/src/scanner/rust.ts
4163
+
4164
+ ```
4165
+ class RustScanner implements Scanner
4166
+ ```
4167
+
4168
+ Use this to scan Rust source files and extract public API elements — functions, structs, enums, impl blocks, and traits — for automated documentation generation or API analysis pipelines.
4169
+
4170
+ `RustScanner` implements the `Scanner` interface and targets `.rs` files, automatically skipping test files under `/tests/` directories.
4171
+
4172
+ ## Methods
4173
+
4174
+ ### `canHandle(filePath: string): boolean`
4175
+ Determines whether this scanner should process a given file.
4176
+
4177
+ | Name | Type | Required | Description |
4178
+ |------|------|
4179
+
4180
+ ### canHandle
4181
+
4182
+ **Type:** method
4183
+ **File:** /Users/debmukherjee/autodocs/src/scanner/rust.ts
4184
+
4185
+ ```
4186
+ canHandle(filePath: string): boolean
4187
+ ```
4188
+
4189
+ Use this to check whether a file path should be processed by the Rust scanner before attempting to scan it. Returns `true` only for `.rs` files that are **not** inside a `/tests/` directory.
4190
+
4191
+ ### Parameters
4192
+
4193
+ | Name | Type | Required | Description |
4194
+ |------|------|----------|-------------|
4195
+ | `filePath` | `string` | Yes | The file path to evaluate (relative or absolute) |
4196
+
4197
+ ### Returns
4198
+
4199
+ | Value | Condition |
4200
+ |-------|-----------|
4201
+ | `true` | Path ends with `.rs` **and** does not contain `/tests/` |
4202
+
4203
+
4204
+ **Example:**
4205
+ ```typescript
4206
+ // Inline implementation of RustScanner.canHandle — no external imports needed
4207
+ class RustScanner {
4208
+ languages = ['rust']
4209
+
4210
+ canHandle(filePath: string): boolean {
4211
+ return /\.rs$/.test(filePath) && !filePath.includes('/tests/')
4212
+ }
4213
+ }
4214
+
4215
+ const scanner = new RustScanner()
4216
+
4217
+ const testCases: Array<{ pa
4218
+ ```
4219
+
4220
+ ### scanFile
4221
+
4222
+ **Type:** method
4223
+ **File:** /Users/debmukherjee/autodocs/src/scanner/rust.ts
4224
+
4225
+ ```
4226
+ async scanFile(filePath: string): Promise<ScanResult>
4227
+ ```
4228
+
4229
+ Use this to extract API elements from a Rust source file, parsing its contents into a structured result containing discovered elements and any errors encountered during scanning.
4230
+
4231
+ Designed for use with non-test `.rs` files, `scanFile` reads the file at the given path and returns a `ScanResult` containing all parsed `APIElement` entries alongside any parsing errors.
4232
+
4233
+ ## Parameters
4234
+
4235
+ | Name | Type | Required | Description |
4236
+ |------|------|----------|-------------|
4237
+ | `filePath` | `string` | ✅ | Abso
4238
+
4239
+ **Example:**
4240
+ ```typescript
4241
+ import { readFileSync, writeFileSync, unlinkSync } from 'fs'
4242
+ import { tmpdir } from 'os'
4243
+ import { join } from 'path'
4244
+
4245
+ // --- Inline types (mirrors the real library's types) ---
4246
+ interface Parameter {
4247
+ name: string
4248
+ type: string
4249
+ }
4250
+
4251
+ interface APIElement {
4252
+ name: string
4253
+ kind: 'function' | 'struct'
4254
+ ```
4255
+
4256
+ ### TypeScriptScanner
4257
+
4258
+ **Type:** class
4259
+ **File:** /Users/debmukherjee/autodocs/src/scanner/typescript.ts
4260
+
4261
+ ```
4262
+ class TypeScriptScanner implements Scanner
4263
+ ```
4264
+
4265
+ Use this to scan TypeScript and JavaScript source files and extract API elements (functions, classes, parameters, and metadata) for automated documentation generation.
4266
+
4267
+ `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.
4268
+
4269
+ ## Properties
4270
+
4271
+ | Property | Type | Description |
4272
+ |----------|------|-------------|
4273
+ | `languages` | `string[]`
4274
+
4275
+ **Example:**
4276
+ ```typescript
4277
+ // ─── Inline types (mirrors the real Scanner/ScanResult interface) ───────────
4278
+
4279
+ type Parameter = {
4280
+ name: string
4281
+ type: string
4282
+ required: boolean
4283
+ description?: string
4284
+ }
4285
+
4286
+ type APIElement = {
4287
+ name: string
4288
+ kind: 'function' | 'class' | 'interface' | 'method' | 'variable'
4289
+ parameters?: Paramet
4290
+ ```
4291
+
4292
+ ### canHandle
4293
+
4294
+ **Type:** method
4295
+ **File:** /Users/debmukherjee/autodocs/src/scanner/typescript.ts
4296
+
4297
+ ```
4298
+ canHandle(filePath: string): boolean
4299
+ ```
4300
+
4301
+ 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.
4302
+
4303
+ Returns `true` for `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, and `.cjs` files. Returns `false` for `.d.ts` declaration files and any other file types.
4304
+
4305
+ ### Parameters
4306
+
4307
+ | Name | Type | Required | Description |
4308
+ |------|------|----------|-------------|
4309
+ | `filePath` | `string` | ✅ | The file path (relative or absolute) to check
4310
+
4311
+ **Example:**
4312
+ ```typescript
4313
+ // Inline implementation matching TypeScriptScanner.canHandle behavior
4314
+ class TypeScriptScanner {
4315
+ languages = ['typescript', 'javascript']
4316
+
4317
+ canHandle(filePath: string): boolean {
4318
+ return /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath) && !filePath.includes('.d.ts')
4319
+ }
4320
+ }
4321
+
4322
+ const scanner = new TypeS
4323
+ ```
4324
+
4325
+ ### scanFile
4326
+
4327
+ **Type:** method
4328
+ **File:** /Users/debmukherjee/autodocs/src/scanner/typescript.ts
4329
+
4330
+ ```
4331
+ async scanFile(filePath: string): Promise<ScanResult>
4332
+ ```
4333
+
4334
+ Use this to extract API elements (functions, classes, methods, parameters) from a TypeScript or JavaScript source file for documentation generation or code analysis.
4335
+
4336
+ `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.
4337
+
4338
+ > **Note:** Does not handle `.d.ts` declaration files — use `canHandle()`
4339
+
4340
+ **Example:**
4341
+ ```typescript
4342
+ import { readFileSync, writeFileSync, unlinkSync } from 'fs'
4343
+ import { join } from 'path'
4344
+
4345
+ // --- Inline types (mirrors the real ScanResult shape) ---
4346
+ type Parameter = {
4347
+ name: string
4348
+ type: string
4349
+ required: boolean
4350
+ description?: string
4351
+ }
4352
+
4353
+ type APIElement = {
4354
+ name: string
4355
+ kind: 'function' |
4356
+ ```
4357
+
4358
+ ### findMdxFiles
4359
+
4360
+ **Type:** function
4361
+ **File:** /Users/debmukherjee/autodocs/src/utils/files.ts
4362
+
4363
+ ```
4364
+ function findMdxFiles(dir: string): string[]
4365
+ ```
4366
+
4367
+ Use this to collect all Markdown and MDX file paths from a directory tree — useful for documentation pipelines, static site generators, or any tooling that needs to process `.md`/`.mdx` content in bulk.
4368
+
4369
+ Recursively walks a directory and returns the absolute paths of every `.md` and `.mdx` file found. Automatically skips hidden directories (e.g. `.git`), `node_modules`, and symlinks to avoid infinite loops and irrelevant files. Stops at a maximum depth of 30 levels.
4370
+
4371
+ ### Parameters
4372
+
4373
+ | Name | Typ
4374
+
4375
+ **Example:**
4376
+ ```typescript
4377
+ import { readdirSync, statSync, lstatSync, mkdirSync, writeFileSync, rmSync } from 'fs'
4378
+ import { join, extname } from 'path'
4379
+
4380
+ // Self-contained implementation of findMdxFiles
4381
+ function findMdxFiles(dir: string): string[] {
4382
+ const files: string[] = []
4383
+
4384
+ function walk(currentDir: string, depth: numbe
4385
+ ```
4386
+
4387
+ ### slugify
4388
+
4389
+ **Type:** function
4390
+ **File:** /Users/debmukherjee/autodocs/src/utils/files.ts
4391
+
4392
+ ```
4393
+ function slugify(str: string): string
4394
+ ```
4395
+
4396
+ Use this to convert any string into a clean, URL-safe slug — stripping special characters, spaces, and leading/trailing hyphens.
4397
+
4398
+ Ideal for generating URL paths from titles, creating file-safe identifiers, or normalizing user input for routing.
4399
+
4400
+ ## Parameters
4401
+
4402
+ | Name | Type | Required | Description |
4403
+ |------|------|----------|-------------|
4404
+ | `str` | `string` | ✅ | The input string to convert into a slug |
4405
+
4406
+ ## Returns
4407
+
4408
+ A lowercase `string` with all non-alphanumeric characters replaced by hyphens
4409
+
4410
+ **Example:**
4411
+ ```typescript
4412
+ // Inline implementation — no imports needed
4413
+ function slugify(str: string): string {
4414
+ return str
4415
+ .toLowerCase()
4416
+ .replace(/[^a-z0-9]+/g, '-')
4417
+ .replace(/^-|-$/g, '')
4418
+ }
4419
+
4420
+ // --- Example Usage ---
4421
+
4422
+ const examples = [
4423
+ "Hello World",
4424
+ "My Awesome Blog Post #42!",
4425
+ " Leading & Trailing Spa
4426
+ ```
4427
+
4428
+ ### parseFrontmatter
4429
+
4430
+ **Type:** function
4431
+ **File:** /Users/debmukherjee/autodocs/src/utils/files.ts
4432
+
4433
+ ```
4434
+ function parseFrontmatter(content: string): { data: Record<string, unknown>; content: string }
4435
+ ```
4436
+
4437
+ Use this to extract structured metadata and body content from Markdown files that use YAML frontmatter blocks (delimited by `---`).
4438
+
4439
+ This is useful when processing `.md` files that contain metadata like titles, dates, tags, or authors at the top — it splits the file into a usable data object and the remaining content body.
4440
+
4441
+ ### Parameters
4442
+
4443
+ | Name | Type | Required | Description |
4444
+ |------|------|----------|-------------|
4445
+ | `content` | `string` | ✅ | The full raw string content of a file, optional
4446
+
4447
+ **Example:**
4448
+ ```typescript
4449
+ // Inline implementation matching the real function's behavior
4450
+ function parseFrontmatter(content: string): { data: Record<string, unknown>; content: string } {
4451
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/)
4452
+ if (!match) return { data: {}, content }
4453
+
4454
+ const yamlStr = m
4455
+ ```
4456
+
4457
+ ### validatePath
4458
+
4459
+ **Type:** function
4460
+ **File:** /Users/debmukherjee/autodocs/src/utils/validation.ts
4461
+
4462
+ ```
4463
+ function validatePath(input: string, mustExist = true): string
4464
+ ```
4465
+
4466
+ Use this to safely resolve and validate file system paths before performing file operations — preventing path traversal issues and catching missing files early.
4467
+
4468
+ `validatePath` resolves a relative or absolute path to its canonical form and optionally checks that the path exists on disk. It guards against directory traversal attacks by flagging paths that escape the current working directory.
4469
+
4470
+ ## Parameters
4471
+
4472
+ | Name | Type | Required | Description |
4473
+ |------|------|----------|-------------|
4474
+ | `inpu
4475
+
4476
+ **Example:**
4477
+ ```typescript
4478
+ import { existsSync } from 'fs'
4479
+ import { resolve } from 'path'
4480
+
4481
+ // Inline implementation — do not import from 'autodocs'
4482
+ function validatePath(input: string, mustExist = true): string {
4483
+ const resolved = resolve(input)
4484
+
4485
+ // Warn on paths outside cwd (but allow absolute paths like /tmp)
4486
+ if (!reso
4487
+ ```
4488
+
4489
+ ### validateUrl
4490
+
4491
+ **Type:** function
4492
+ **File:** /Users/debmukherjee/autodocs/src/utils/validation.ts
4493
+
4494
+ ```
4495
+ function validateUrl(input: string): string
4496
+ ```
4497
+
4498
+ Use this to validate and sanitize URL strings before making HTTP requests or storing user-provided URLs. Ensures the input is a well-formed URL with a safe protocol (`http:` or `https:`), throwing descriptive errors for invalid input.
4499
+
4500
+ ## Parameters
4501
+
4502
+ | Name | Type | Required | Description |
4503
+ |------|------|----------|-------------|
4504
+ | `input` | `string` | ✅ | The URL string to validate. Must be a well-formed URL using `http:` or `https:` protocol. |
4505
+
4506
+ ## Returns
4507
+
4508
+ | Condition | Result |
4509
+ |-----------
4510
+
4511
+ **Example:**
4512
+ ```typescript
4513
+ // Inline implementation of validateUrl — no external imports needed
4514
+ function validateUrl(input: string): string {
4515
+ try {
4516
+ const url = new URL(input)
4517
+ if (!['http:', 'https:'].includes(url.protocol)) {
4518
+ throw new Error(`Invalid protocol: ${url.protocol}`)
4519
+ }
4520
+ return input
4521
+ } catch
4522
+ ```
4523
+
4524
+ ### validateSlug
4525
+
4526
+ **Type:** function
4527
+ **File:** /Users/debmukherjee/autodocs/src/utils/validation.ts
4528
+
4529
+ ```
4530
+ function validateSlug(input: string): string
4531
+ ```
4532
+
4533
+ Use this to validate that a string is a safe slug before using it in URLs, file paths, or database identifiers. Throws immediately if the input contains invalid characters, so you can catch bad data early.
4534
+
4535
+ **Validation rule:** Only alphanumeric characters (`a-z`, `A-Z`, `0-9`), hyphens (`-`), and underscores (`_`) are allowed. Spaces, dots, slashes, and any other special characters will cause a throw.
4536
+
4537
+ ### Parameters
4538
+
4539
+ | Name | Type | Required | Description |
4540
+ |------|------|----------|----------
4541
+
4542
+ **Example:**
4543
+ ```typescript
4544
+ // Inline implementation — no external imports needed
4545
+ function validateSlug(input: string): string {
4546
+ if (!/^[a-zA-Z0-9_-]+$/.test(input)) {
4547
+ throw new Error(
4548
+ `Invalid slug: ${input}. Only alphanumeric, hyphens, and underscores allowed.`
4549
+ )
4550
+ }
4551
+ return input
4552
+ }
4553
+
4554
+ // --- Valid slug exampl
4555
+ ```
4556
+
4557
+ ### sanitizeForShell
4558
+
4559
+ **Type:** function
4560
+ **File:** /Users/debmukherjee/autodocs/src/utils/validation.ts
4561
+
4562
+ ```
4563
+ function sanitizeForShell(input: string): string
4564
+ ```
4565
+
4566
+ Use this to validate and sanitize strings before passing them to shell commands, git operations, or filesystem paths — preventing command injection and unsafe character exploits.
4567
+
4568
+ Accepts an input string and throws immediately if it contains any characters outside the safe allowlist (`a-z`, `A-Z`, `0-9`, `/`, `_`, `~`, `.`, `^`, `@`, `{`, `}`, `-`). Returns the original string unchanged if it passes validation.
4569
+
4570
+ ## Parameters
4571
+
4572
+ | Name | Type | Required | Description |
4573
+ |------|------|----------|--
4574
+
4575
+ **Example:**
4576
+ ```typescript
4577
+ // Inline implementation — no external imports needed
4578
+ function sanitizeForShell(input: string): string {
4579
+ // Only allow safe characters for git refs, filenames, etc.
4580
+ if (!/^[a-zA-Z0-9/_~.^@{}\-]+$/.test(input)) {
4581
+ throw new Error(`Unsafe characters in input: ${input}`)
4582
+ }
4583
+ return input
4584
+ }
4585
+
4586
+ //
4587
+ ```
4588
+