@gitpagedocs/cli 1.1.44

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 (66) hide show
  1. package/README.md +169 -0
  2. package/ai/application/ai-command.ts +24 -0
  3. package/ai/application/ai-provider-factory.ts +22 -0
  4. package/ai/application/run-ai-cli-command.ts +136 -0
  5. package/ai/config.ts +22 -0
  6. package/ai/core/models/ai-cli-config.ts +31 -0
  7. package/ai/core/ports/illm-provider.ts +32 -0
  8. package/ai/infrastructure/ai-config-file.ts +32 -0
  9. package/ai/infrastructure/file-system-adapter.ts +83 -0
  10. package/ai/infrastructure/llm/tools-llm-provider.ts +54 -0
  11. package/ai/presentation/ai-prompts.ts +239 -0
  12. package/application/config-only/handler.mjs +55 -0
  13. package/application/home/handler.mjs +83 -0
  14. package/application/ports/cli-runtime-ports.ts +87 -0
  15. package/application/report/config-only-reporter.mjs +62 -0
  16. package/application/use-cases/dispatch-mode.ts +18 -0
  17. package/builders/config-orchestrator.mjs +40 -0
  18. package/builders/root-config-builder.mjs +54 -0
  19. package/builders/route-builders.mjs +111 -0
  20. package/builders/source-viewer.mjs +330 -0
  21. package/builders/theme-template.mjs +75 -0
  22. package/builders/version-config-builder.mjs +151 -0
  23. package/content/docs-en.mjs +542 -0
  24. package/content/docs-es.mjs +459 -0
  25. package/content/docs-pt.mjs +459 -0
  26. package/content/docs.mjs +9 -0
  27. package/contracts/doc-versions.mjs +1 -0
  28. package/contracts/index.mjs +1 -0
  29. package/data/default-site-config.mjs +312 -0
  30. package/data/i18n-langmenu.mjs +122 -0
  31. package/data/i18n-translations.mjs +20 -0
  32. package/data/layouts.mjs +353 -0
  33. package/data/path-mappings.mjs +34 -0
  34. package/data/route-metas.mjs +73 -0
  35. package/data/theme-colors.mjs +387 -0
  36. package/data/urls.mjs +7 -0
  37. package/data/version-constants.mjs +3 -0
  38. package/domain/models/cli-options.ts +18 -0
  39. package/domain/services/sanitize-segment.mjs +7 -0
  40. package/home/constants.mjs +4 -0
  41. package/home/home-file-writer.mjs +20 -0
  42. package/home/templates.mjs +48 -0
  43. package/index.mjs +26 -0
  44. package/infrastructure/config-only/runtime.mjs +17 -0
  45. package/infrastructure/home/runtime.mjs +37 -0
  46. package/package.json +60 -0
  47. package/presentation/commands/ai-info.ts +57 -0
  48. package/presentation/commands/config-info.ts +24 -0
  49. package/presentation/commands/diagnostics.ts +70 -0
  50. package/presentation/commands/docs.ts +37 -0
  51. package/presentation/commands/mcp.ts +20 -0
  52. package/presentation/commands/pages.ts +91 -0
  53. package/presentation/commands/run-command.ts +62 -0
  54. package/presentation/index.ts +108 -0
  55. package/presentation/options/parser.ts +104 -0
  56. package/presentation/options/resolver.ts +25 -0
  57. package/presentation/options/schema.ts +10 -0
  58. package/presentation/ui/banner.ts +13 -0
  59. package/presentation/ui/clack.ts +74 -0
  60. package/presentation/ui/prompts.ts +64 -0
  61. package/runtime/doc-path-resolver.mjs +57 -0
  62. package/runtime/git-ops.mjs +110 -0
  63. package/runtime/output.mjs +122 -0
  64. package/runtime/workflow.mjs +144 -0
  65. package/start.mjs +12 -0
  66. package/ui/logger.mjs +9 -0
@@ -0,0 +1,542 @@
1
+ export const docsEn = {
2
+ index: `# Git Page Docs
3
+
4
+ Git Page Docs is a multilingual documentation runtime for repositories that ship a \`gitpagedocs/\` folder.
5
+
6
+ ## What this project delivers
7
+
8
+ - Multilingual markdown rendering (\`en\`, \`pt\`, \`es\`)
9
+ - Version-aware docs routing (\`/v/:version\`)
10
+ - Theme system with JSON templates
11
+ - Local and GitHub Pages execution modes
12
+ - Optional repository search + remote rendering
13
+
14
+ ## Folder contract
15
+
16
+ The runtime expects this structure:
17
+
18
+ - \`gitpagedocs/config.json\`
19
+ - \`gitpagedocs/docs/<lang>/*.md\`
20
+ - \`gitpagedocs/docs/versions/<version>/config.json\`
21
+ - \`gitpagedocs/docs/versions/<version>/<lang>/*.md\`
22
+ - \`gitpagedocs/layouts/layoutsConfig.json\`
23
+ - \`gitpagedocs/layouts/templates/*.json\`
24
+
25
+ ## Quick navigation
26
+
27
+ - Open **Getting Started** for local setup.
28
+ - Open **Configuration** for full \`config.json\` explanation.
29
+ - Open **Deployment** for local, server, and GitHub Pages behavior.
30
+ - Open **Architecture** for code map and data flow.
31
+ - Open **Themes and layouts** for template authoring details.
32
+ - Open **Authorized routes** for key, roles, and external auth setup.
33
+ - Open **FAQ** for troubleshooting.
34
+ `,
35
+ gettingStarted: `# Getting Started
36
+
37
+ This guide configures your repository from zero to running docs.
38
+
39
+ ## Prerequisites
40
+
41
+ - Node.js 20+
42
+ - npm 10+
43
+
44
+ ## Install and generate
45
+
46
+ 1. Install package:
47
+ - \`npm install gitpagedocs\`
48
+ 2. Generate docs config and versions:
49
+ - \`npx gitpagedocs\`
50
+ 3. Optional: generate local layouts/templates:
51
+ - \`npx gitpagedocs --layoutconfig\`
52
+
53
+ ## Local run
54
+
55
+ 1. Development:
56
+ - \`npm run dev\`
57
+ 2. Production locally:
58
+ - \`npm run build\`
59
+ - \`npm start\`
60
+
61
+ ## CLI behavior
62
+
63
+ \`npx gitpagedocs\` generates only artifacts in \`gitpagedocs/\`:
64
+
65
+ - JSON + markdown docs assets
66
+ - No \`index.html\`
67
+ - No \`index.js\`
68
+ - No install command execution
69
+
70
+ ## Repository search mode
71
+
72
+ Local repository search is controlled by:
73
+
74
+ - \`GITPAGEDOCS_REPOSITORY_SEARCH=true\`
75
+ - \`GITPAGEDOCS_REPOSITORY_SEARCH=false\`
76
+
77
+ On GitHub Pages builds (\`GITHUB_ACTIONS=true\`), repository-search home is enabled.
78
+ `,
79
+ projectOverview: `# Project Overview
80
+
81
+ Git Page Docs is a **pnpm + turborepo monorepo** that turns a repository's \`gitpagedocs/\` folder into a multilingual, versioned documentation site — with an integrated AI assistant and a Model Context Protocol (MCP) server.
82
+
83
+ ## Monorepo packages
84
+
85
+ - **frontend/** — Next.js 15 (App Router, React 19) documentation viewer, static-exported for GitHub Pages.
86
+ - **cli/** — the published \`gitpagedocs\` npm package (\`npm install -g gitpagedocs\`): scaffolds the docs contract, generates docs with AI, configures Pages, and runs the MCP server.
87
+ - **tools/** — \`@gitpagedocs/tools\`, the shared business-logic core: the 14-provider AI system, the encrypted credential vault, the config loader, caches, and the logger.
88
+ - **mcp/** — \`@gitpagedocs/mcp\`, a Model Context Protocol server (20 tools + 7 resources).
89
+ - **gitpagedocs/** — the user contract: \`config.json\`, versioned docs, and layouts.
90
+
91
+ ## Stack
92
+
93
+ - Next.js 15 (App Router) + React 19 + TypeScript; static export for GitHub Pages
94
+ - gray-matter + marked for Markdown; react-icons
95
+ - pnpm workspaces + turborepo; Vitest + Playwright; ESLint
96
+
97
+ ## Highlights
98
+
99
+ - Multilingual (\`en\`, \`pt\`, \`es\`) and version-aware routing (\`/v/:version\`)
100
+ - 14-provider AI system (OpenAI, Anthropic, Gemini, Ollama, Mistral, DeepSeek, Cohere, Groq, xAI, and more) with streaming
101
+ - AI API keys stored **encrypted at rest** (AES-256-GCM) behind a local password gate — never plaintext
102
+ - In-docs **AI chat drawer** plus a dedicated **\`/ai\` console**
103
+ - 36-theme layout system; local and GitHub Pages execution modes
104
+ `,
105
+ functionalities: `# Functionalities
106
+
107
+ Complete reference of CLI options, configuration keys, and runtime features.
108
+
109
+ ## CLI commands
110
+
111
+ | Command | Description |
112
+ |---------|--------------|
113
+ | \`gitpagedocs\` | Generate config and docs in \`gitpagedocs/\` |
114
+ | \`gitpagedocs --layoutconfig\` | Also generate local layouts/templates |
115
+ | \`gitpagedocs --home\` | Standalone distribution (\`gitpagedocshome/\`) |
116
+ | \`gitpagedocs --push --owner X --repo Y\` | Setup workflow, commit, push |
117
+ | \`gitpagedocs --interactive\` / \`-i\` | Interactive mode with prompts |
118
+ | \`gitpagedocs ai\` | Interactive AI documentation generator |
119
+ | \`gitpagedocs provider [id]\` / \`models [provider]\` | List AI providers / catalog models |
120
+ | \`gitpagedocs document[:repo\\|:file\\|:folder]\` | Generate documentation with AI |
121
+ | \`gitpagedocs deploy\` / \`pages [actions\\|deploy]\` | Configure GitHub Pages via Actions + push |
122
+ | \`gitpagedocs docs\` | Refresh README/CONTRIBUTING/SECURITY managed regions |
123
+ | \`gitpagedocs doctor\` / \`version\` / \`update\` | Diagnostics / version / update hint |
124
+ | \`gitpagedocs mcp start\` | Start the MCP server over stdio |
125
+
126
+ Install globally with \`npm install -g gitpagedocs\`, or run one-off with \`npx gitpagedocs\`.
127
+
128
+ ## CLI options
129
+
130
+ | Option | Description |
131
+ |--------|-------------|
132
+ | \`--owner <user>\` | GitHub owner |
133
+ | \`--repo <repo>\` | GitHub repository |
134
+ | \`--path <subpath>\` | Docs subpath (e.g. \`docs\`); without it, base path = repo name for correct CSS/JS on project sites |
135
+ | \`--output <dir>\` | Output directory (default: \`gitpagedocs\`) |
136
+ | \`--search true|false\` | Enable/disable repository search (\`--home\`) |
137
+ | \`--layoutconfig\` | Generate \`gitpagedocs/layouts/\` |
138
+ | \`--push\` | Create workflow, commit artifacts, push |
139
+ | \`--home\` | Generate \`gitpagedocshome/\` (static + .env + Dockerfile) |
140
+
141
+ ## Generated output
142
+
143
+ - \`gitpagedocs/config.json\` – root config
144
+ - \`gitpagedocs/icon.svg\` – default icon
145
+ - \`gitpagedocs/docs/versions/<ver>/config.json\` – per-version routes
146
+ - \`gitpagedocs/docs/versions/<ver>/{en,pt,es}/*.md\` – markdown docs
147
+ - \`gitpagedocs/docs/versions/<ver>/{en,pt,es}/source-viewer\` – GitHub-style source code viewer
148
+ - \`gitpagedocs/layouts/\` – only with \`--layoutconfig\`
149
+
150
+ ## Content types
151
+
152
+ | Type | Config key | Description |
153
+ |------|------------|-------------|
154
+ | Markdown | \`routes-md\` | .md files with \`path\` per language |
155
+ | HTML | \`routes-html\` | \`path\` (e.g. source-viewer) or \`url\` for external |
156
+ | Video | \`routes-video\` | \`video.pathVideo\`, \`video.videoType\` |
157
+ | Audio | \`routes-audio\` | \`audio.pathAudio\`, \`audio.audioType\` |
158
+
159
+ ## Source code viewer
160
+
161
+ The CLI generates a **Source code** page per version. It scans \`src/\`, \`cli/\`, and root files (README.md, package.json, next.config.ts, etc.) and builds a GitHub-style dark viewer with:
162
+
163
+ - File tree sidebar with folder collapse/expand
164
+ - Search filter for files
165
+ - Syntax highlighting (TypeScript, JavaScript, JSON, CSS, Markdown)
166
+ - Copy button, line numbers
167
+ - README.md preview/code toggle
168
+ - Expand all / Collapse all controls
169
+
170
+ ## Config keys (site)
171
+
172
+ - \`name\`, \`defaultLanguage\`, \`supportedLanguages\`
173
+ - \`docsVersion\`, \`rendering\`, \`ThemeDefault\`, \`ThemeModeDefault\`
174
+ - \`ProjectLink\`, \`layoutsConfigPathOficial\`, \`layoutsConfigPath\`
175
+
176
+ ## Environment variables
177
+
178
+ - \`GITPAGEDOCS_REPOSITORY_SEARCH\` – repository search (local)
179
+ - \`GITHUB_ACTIONS\` – GitHub Pages build mode
180
+
181
+ ## AI assistant
182
+
183
+ The docs ship an AI assistant in two surfaces: an in-docs **chat drawer** (the ✨ button in the sidebar, enabled via \`site.AiChatEnabled\`) and a dedicated **\`/ai\` console** page.
184
+
185
+ - **14 providers** via one shared core: OpenAI, Anthropic, Gemini, OpenRouter, Ollama, Azure OpenAI, Mistral, DeepSeek, Cohere, Groq, xAI, Together, Fireworks, Perplexity.
186
+ - **Model selection** — pick from each provider's catalog (\`gitpagedocs models <provider>\`) or type a custom id.
187
+ - **Encrypted at rest** — your API key is sealed with AES-256-GCM behind a **local password** (one unlock per session) and is never stored in plaintext or logged. A legacy plaintext key is migrated and wiped on first unlock.
188
+ - **AI documentation generation** — \`gitpagedocs ai\` scans chosen paths and writes multilingual markdown (pt/en/es); reusable via \`.gitpagedocsconfig\`.
189
+
190
+ ## MCP server
191
+
192
+ \`gitpagedocs mcp start\` runs a Model Context Protocol server (stdio) exposing **20 tools** (filesystem, AI, doc generation/analysis) and **7 resources** (\`project://structure|docs|config|repository|readme|ai/providers|ai/models\`) for editors and AI agents.
193
+ `,
194
+ githubIssuesProjects: `# GitHub Issues and Projects
195
+
196
+ Learn how to use GitHub Issues and Projects to manage your work.
197
+
198
+ ## Issues
199
+
200
+ - Track bugs, features, and tasks
201
+ - Assignees, labels, milestones
202
+ - Discussions and linked PRs
203
+
204
+ ## Projects
205
+
206
+ - Kanban boards
207
+ - Tables and roadmaps
208
+ - Custom fields and automation
209
+ `,
210
+ gitIntroduction: `# Introduction to Git
211
+
212
+ Basic Git concepts for beginners.
213
+
214
+ ## Key concepts
215
+
216
+ - **Repository**: A project folder tracked by Git
217
+ - **Commit**: A snapshot of changes
218
+ - **Branch**: Alternative line of development
219
+ - **Remote**: Shared repository (e.g. on GitHub)
220
+
221
+ ## Common commands
222
+
223
+ - \`git init\` - Initialize a repo
224
+ - \`git add\` - Stage changes
225
+ - \`git commit\` - Create a snapshot
226
+ - \`git push\` - Send to remote
227
+ `,
228
+ authorizedRoutes: `# Authorized Routes
229
+
230
+ Protect routes by access key, required roles, and external authentication providers.
231
+
232
+ ## Version config location
233
+
234
+ Configure this at:
235
+
236
+ - \`gitpagedocs/docs/versions/<version>/config.json\`
237
+
238
+ ## Global auth section
239
+
240
+ Use top-level \`auth\` in version config:
241
+
242
+ - \`accessKeys\`: map of key ids to expected secrets
243
+ - \`rolesStorageKey\`: localStorage key for role bootstrap
244
+ - \`providers\`: external providers list (\`authjs\`, \`clerk\`, \`firebase\`, \`jwt\`)
245
+
246
+ ## Route-level authorization
247
+
248
+ Inside each route (\`routes-md\`, \`routes-html\`, \`routes-video\`):
249
+
250
+ - \`authorization.accessKeyId\`
251
+ - \`authorization.requiredRoles\`
252
+ - \`authorization.requireExternalAuth\`
253
+ - \`authorization.allowedProviders\`
254
+
255
+ ## Phases
256
+
257
+ ### Phase A - Access key
258
+
259
+ Set \`authorization.accessKeyId\` and define that key in \`auth.accessKeys\`.
260
+
261
+ ### Phase B - Roles
262
+
263
+ Set \`authorization.requiredRoles\` with one or more roles.
264
+
265
+ Roles can come from:
266
+
267
+ - query param \`?authRoles=admin,maintainer\`
268
+ - localStorage (\`rolesStorageKey\`)
269
+ - external provider claims
270
+
271
+ ### Phase C - External providers
272
+
273
+ Set \`authorization.requireExternalAuth=true\` and optionally \`allowedProviders\`.
274
+
275
+ Supported adapters:
276
+
277
+ - Auth.js (\`type: "authjs"\`)
278
+ - Clerk (\`type: "clerk"\`)
279
+ - Firebase Auth (\`type: "firebase"\`)
280
+ - Custom JWT (\`type: "jwt"\`)
281
+
282
+ ## Example
283
+
284
+ \`\`\`json
285
+ {
286
+ "auth": {
287
+ "accessKeys": {
288
+ "docs-key": "open-gitpagedocs-docs"
289
+ },
290
+ "providers": [
291
+ { "type": "authjs", "enabled": true, "sessionEndpoint": "/api/auth/session" },
292
+ { "type": "jwt", "enabled": true, "tokenStorageKey": "git-page-docs:jwt-token" }
293
+ ]
294
+ },
295
+ "routes-md": [
296
+ {
297
+ "id": 6,
298
+ "path": {
299
+ "en": "gitpagedocs/docs/versions/1.1.1/en/authorized-routes.md",
300
+ "pt": "gitpagedocs/docs/versions/1.1.1/pt/authorized-routes.md",
301
+ "es": "gitpagedocs/docs/versions/1.1.1/es/authorized-routes.md"
302
+ },
303
+ "authorization": {
304
+ "accessKeyId": "docs-key",
305
+ "requiredRoles": ["maintainer"],
306
+ "requireExternalAuth": true,
307
+ "allowedProviders": ["authjs", "jwt"]
308
+ }
309
+ }
310
+ ]
311
+ }
312
+ \`\`\`
313
+ `,
314
+ configuration: `# Configuration
315
+
316
+ Runtime configuration lives in \`gitpagedocs/config.json\`.
317
+
318
+ ## \`site\` section
319
+
320
+ Important keys:
321
+
322
+ - \`name\`
323
+ - \`defaultLanguage\`
324
+ - \`supportedLanguages\`
325
+ - \`docsVersion\`
326
+ - \`rendering\`
327
+ - \`ThemeDefault\`
328
+ - \`ThemeModeDefault\`
329
+ - \`ProjectLink\`
330
+
331
+ ## Layout source keys
332
+
333
+ - \`layoutsConfigPathOficial\`
334
+ - \`layoutsConfigPathOficialUrl\`
335
+ - \`layoutsConfigPathTemplatesOficial\`
336
+ - \`layoutsConfigPath\`
337
+ - \`layoutsConfigPathTemplates\`
338
+
339
+ Behavior:
340
+
341
+ - If \`layoutsConfigPathOficial=true\`, runtime prefers official layout/template sources.
342
+ - If \`layoutsConfigPathOficial=false\`, runtime prefers repository-local/custom layout sources.
343
+
344
+ ## \`VersionControl\` section
345
+
346
+ \`VersionControl.versions\` defines:
347
+
348
+ - \`id\`
349
+ - \`path\`
350
+ - optional metadata links (\`ProjectLink\`, \`branch\`, \`release\`, \`commit\`)
351
+
352
+ ## Navigation
353
+
354
+ - \`routes\`: markdown paths per language (legacy)
355
+ - \`menus-header\`: hierarchical menu model
356
+ - \`translations\`: UI labels
357
+
358
+ ## Authorization (version config)
359
+
360
+ - \`auth\`: global authorization runtime settings for that version
361
+ - \`auth.accessKeys\`: key map used by \`authorization.accessKeyId\`
362
+ - \`auth.rolesStorageKey\`: localStorage key for role bootstrap
363
+ - \`auth.providers\`: provider adapters (\`authjs\`, \`clerk\`, \`firebase\`, \`jwt\`)
364
+
365
+ ## Content types (version config)
366
+
367
+ Version configs support multiple content types:
368
+
369
+ - \`routes-md\`: Markdown routes with optional \`title\`, \`description\` (centered via \`titlePosition\`, \`descriptionPosition\`)
370
+ - \`routes-html\`: HTML page paths per language
371
+ - \`routes-video\`: Video config with \`video.videoType\` (youtube, vimeo, mp4, etc.) and \`video.pathVideo\`
372
+ - \`routes-audio\`: Audio config with \`audio.audioType\` (youtube, mp3, etc.) and \`audio.pathAudio\`
373
+ - \`authorization\` (md/html/video): route guard by access key, roles, and external auth
374
+ - \`menus-header-md\`, \`menus-header-html\`, \`menus-header-video\`, \`menus-header-audio\`: menus per type
375
+ - \`hierarchyPage\`: container order on page \`{ md: 0, html: 1, video: 2, audio: 3 }\`
376
+ - \`hierarchyMenu\`: menu section order \`{ md: 0, html: 1, video: 2, audio: 3 }\`
377
+
378
+ Each route can include \`title\`, \`description\` (per language), \`titleCss\`, \`titlePosition: "center"\`, \`descriptionPosition: "center"\`, \`titleIsVisible\`, \`descriptionIsVisible\`.
379
+
380
+ ## Route-level variables (blockLink, container, url, browseAll)
381
+
382
+ Per-route options for \`routes-md\`, \`routes-html\`, \`routes-video\`, and \`routes-audio\`:
383
+
384
+ - **\`blockLink\`** (default: true) – For HTML: if true, links open in a new tab (\`target="_blank"\`); if false, links open in the same context.
385
+ - **\`container\`** – \`"full"\` = auto-extend height; number (e.g. \`500\`) = fixed height in px with overflow auto. Applies to md, html, video, and audio containers.
386
+ - **\`url\`** – For \`routes-html\` only: \`Record<LanguageCode, string>\` with external URLs. When set, the iframe uses \`src={url}\` instead of local HTML via \`srcDoc\`. Routes with \`url\` do not generate local HTML files.
387
+ - **\`browseAll\`** (default: false) – If true, the container shows Previous/Next buttons to browse all items of that type without changing the page.
388
+
389
+ ## Content types: path vs url (HTML)
390
+
391
+ - **Markdown (\`routes-md\`)**: always uses \`path\` pointing to local \`.md\` files.
392
+ - **HTML (\`routes-html\`)**: uses \`path\` for local HTML files (no \`.html\` extension in config, e.g. \`source-viewer\`) or \`url\` for external URLs. When \`url\` is set, the iframe loads the external page; no local file is generated. The CLI generates a **Source code** viewer (GitHub-style) per version.
393
+ - **Video (\`routes-video\`)**: uses \`video.pathVideo\` and \`video.videoType\` (youtube, vimeo, mp4, etc.).
394
+ - **Audio (\`routes-audio\`)**: uses \`audio.pathAudio\` and \`audio.audioType\` (youtube, mp3, etc.). No autoplay by default.
395
+
396
+ ## Environment variables
397
+
398
+ - \`GITPAGEDOCS_REPOSITORY_SEARCH\`: enable/disable remote repository search in local runtime
399
+ - \`GITHUB_ACTIONS\`: enables GitHub Pages specific runtime behavior
400
+ `,
401
+ deployment: `# Deployment
402
+
403
+ Git Page Docs supports two usage models:
404
+
405
+ 1. Use the official viewer site
406
+ 2. Self-host your own GitHub Pages runtime
407
+
408
+ ## Official viewer site
409
+
410
+ Use:
411
+
412
+ - \`https://vidigal-code.github.io/git-page-docs/\`
413
+
414
+ Provide owner + repository to load docs from repositories that contain \`gitpagedocs/\`.
415
+
416
+ ## Self-hosted GitHub Pages
417
+
418
+ 1. Generate docs:
419
+ - \`npx gitpagedocs\`
420
+ - or \`npx gitpagedocs --layoutconfig\` for local templates
421
+ 2. Set \`site.rendering\` in \`gitpagedocs/config.json\`:
422
+ - \`https://<your-user>.github.io/<your-repo>/\`
423
+ 3. Build and validate:
424
+ - \`npm run lint\`
425
+ - \`npm run build\`
426
+ 4. Deploy with GitHub Pages workflow.
427
+
428
+ When \`GITHUB_ACTIONS=true\`, runtime applies GitHub Pages behavior.
429
+
430
+ ## npm publish flows
431
+
432
+ Recommended: GitHub Release + CI publish.
433
+
434
+ Manual fallback:
435
+
436
+ 1. \`npm whoami\`
437
+ 2. \`npm run lint\`
438
+ 3. \`npm run build\`
439
+ 4. \`npm pack --ignore-scripts\`
440
+ 5. \`npm version patch\`
441
+ 6. \`npm publish --access public\`
442
+ `,
443
+ architecture: `# Architecture
444
+
445
+ A pnpm + turborepo monorepo where all business logic lives in one shared core (\`tools/\`); the frontend, CLI, and MCP server are thin consumers of it.
446
+
447
+ ## Packages
448
+
449
+ - **frontend/** — Next.js viewer (Feature-Sliced: \`app / widgets / features / entities / shared\`); static export.
450
+ - **cli/** — the published \`gitpagedocs\` bin (hexagonal: \`presentation / application / domain / infrastructure\`) + \`cli/ai/\` (the AI documentation CLI).
451
+ - **tools/** — \`@gitpagedocs/tools\`: \`ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ ports/\`.
452
+ - **mcp/** — \`@gitpagedocs/mcp\`: MCP tools + resources delegating to \`tools/\`.
453
+
454
+ ## Main runtime modules (frontend)
455
+
456
+ - \`frontend/src/app/[[...repo]]/page.tsx\` — route parser, static params, shell selection (docs vs repository-search).
457
+ - \`frontend/src/entities/docs/api/load-docs-data.ts\` — local/remote config loading, version resolution, markdown parse, layouts + themes.
458
+ - \`frontend/src/widgets/docs-shell/docs-shell.tsx\` — UI rendering, language/version/theme state, URL sync, AI chat drawer mount.
459
+
460
+ ## Security: encrypted AI credentials
461
+
462
+ The \`/ai\` console and the chat drawer gate access behind a local password that derives (PBKDF2) an AES-256-GCM key; keys live encrypted in \`localStorage\` and are decrypted only for the session (\`@gitpagedocs/tools/security\`).
463
+
464
+ ## Data flow
465
+
466
+ 1. Request route arrives (\`/owner/repo/v/x.y.z\` or local equivalent)
467
+ 2. Config is resolved (local or remote repo)
468
+ 3. Version config overrides base routes/menus
469
+ 4. Markdown is loaded and converted to HTML
470
+ 5. Layout template is resolved and CSS vars applied
471
+ 6. Shell renders content + controls
472
+
473
+ ## Reliability points
474
+
475
+ - fallback strategy for layout/template loading
476
+ - resilient markdown loading per language
477
+ - localStorage sync for user language/version/theme
478
+ `,
479
+ themes: `# Themes and Layouts
480
+
481
+ Themes are JSON templates mapped by \`layoutsConfig.json\`.
482
+
483
+ ## Strategy options
484
+
485
+ - Default mode (\`npx gitpagedocs\`): use official layouts/templates from the upstream repository.
486
+ - Local mode (\`npx gitpagedocs --layoutconfig\`): generate and use local templates from your repository.
487
+
488
+ ## Local layout files
489
+
490
+ - \`gitpagedocs/layouts/layoutsConfig.json\`
491
+ - \`gitpagedocs/layouts/layoutsFallbackConfig.json\`
492
+ - \`gitpagedocs/layouts/templates/*.json\`
493
+
494
+ ## Template model
495
+
496
+ Each template usually includes:
497
+
498
+ - \`id\`, \`name\`, \`author\`, \`version\`
499
+ - \`mode\` + dark/light pairing metadata
500
+ - \`colors\`
501
+ - \`typography\`
502
+ - \`components\`
503
+ - \`animations\`
504
+
505
+ ## Runtime behavior
506
+
507
+ - Active theme is resolved from config/user selection.
508
+ - Light/dark toggle resolves paired theme via reference.
509
+ - CSS variables are generated from template tokens.
510
+ - Runtime includes fallback behavior if a source is unavailable.
511
+ `,
512
+ faq: `# FAQ
513
+
514
+ ## Why are remote repositories not opening locally?
515
+
516
+ Check:
517
+
518
+ - \`GITPAGEDOCS_REPOSITORY_SEARCH=true\` in \`.env\`
519
+ - target repo contains \`gitpagedocs/config.json\`
520
+ - target repo markdown paths match its routes config
521
+
522
+ ## Why does a version path return wrong content?
523
+
524
+ Check:
525
+
526
+ - \`VersionControl.versions[*].path\` in \`gitpagedocs/config.json\`
527
+ - that version config has valid \`routes\` and \`menus-header\`
528
+ - markdown files exist for each language
529
+
530
+ ## Why does theme selection not apply correctly?
531
+
532
+ Check:
533
+
534
+ - \`layoutsConfig.json\` references valid template files
535
+ - template ids are unique
536
+ - selected theme exists in loaded themes map
537
+
538
+ ## Why can GitHub Pages behave differently from local?
539
+
540
+ Because GitHub Pages build mode enables repository-search home and static-export specific behavior.
541
+ `,
542
+ };