living-documentation 7.0.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 (173) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +329 -0
  3. package/dist/bin/cli.d.ts +3 -0
  4. package/dist/bin/cli.d.ts.map +1 -0
  5. package/dist/bin/cli.js +62 -0
  6. package/dist/bin/cli.js.map +1 -0
  7. package/dist/src/frontend/admin.html +1073 -0
  8. package/dist/src/frontend/annotations.js +546 -0
  9. package/dist/src/frontend/boot.js +90 -0
  10. package/dist/src/frontend/config.js +19 -0
  11. package/dist/src/frontend/dark-mode.js +20 -0
  12. package/dist/src/frontend/diagram/alignment.js +161 -0
  13. package/dist/src/frontend/diagram/clipboard.js +172 -0
  14. package/dist/src/frontend/diagram/constants.js +109 -0
  15. package/dist/src/frontend/diagram/debug.js +43 -0
  16. package/dist/src/frontend/diagram/edge-panel.js +260 -0
  17. package/dist/src/frontend/diagram/edge-rendering.js +12 -0
  18. package/dist/src/frontend/diagram/grid.js +78 -0
  19. package/dist/src/frontend/diagram/groups.js +102 -0
  20. package/dist/src/frontend/diagram/history.js +153 -0
  21. package/dist/src/frontend/diagram/image-name-modal.js +48 -0
  22. package/dist/src/frontend/diagram/image-upload.js +36 -0
  23. package/dist/src/frontend/diagram/label-editor.js +115 -0
  24. package/dist/src/frontend/diagram/link-panel.js +144 -0
  25. package/dist/src/frontend/diagram/main.js +299 -0
  26. package/dist/src/frontend/diagram/network.js +1473 -0
  27. package/dist/src/frontend/diagram/node-panel.js +267 -0
  28. package/dist/src/frontend/diagram/node-rendering.js +773 -0
  29. package/dist/src/frontend/diagram/persistence.js +161 -0
  30. package/dist/src/frontend/diagram/ports.js +386 -0
  31. package/dist/src/frontend/diagram/selection-overlay.js +336 -0
  32. package/dist/src/frontend/diagram/state.js +39 -0
  33. package/dist/src/frontend/diagram/t.js +3 -0
  34. package/dist/src/frontend/diagram/toast.js +21 -0
  35. package/dist/src/frontend/diagram/unlock-hold.js +182 -0
  36. package/dist/src/frontend/diagram/zoom.js +20 -0
  37. package/dist/src/frontend/diagram-link-modal.js +137 -0
  38. package/dist/src/frontend/diagram.html +1279 -0
  39. package/dist/src/frontend/documents.js +373 -0
  40. package/dist/src/frontend/export.js +338 -0
  41. package/dist/src/frontend/i18n/en.json +406 -0
  42. package/dist/src/frontend/i18n/fr.json +406 -0
  43. package/dist/src/frontend/i18n.js +32 -0
  44. package/dist/src/frontend/image-paste.js +101 -0
  45. package/dist/src/frontend/index.html +2314 -0
  46. package/dist/src/frontend/misc.js +25 -0
  47. package/dist/src/frontend/new-doc-modal.js +260 -0
  48. package/dist/src/frontend/new-folder-modal.js +174 -0
  49. package/dist/src/frontend/search.js +157 -0
  50. package/dist/src/frontend/sidebar-helpers.js +58 -0
  51. package/dist/src/frontend/sidebar.js +182 -0
  52. package/dist/src/frontend/snippet-detect.js +25 -0
  53. package/dist/src/frontend/snippet-table.js +85 -0
  54. package/dist/src/frontend/snippet-tree.js +94 -0
  55. package/dist/src/frontend/snippets.js +534 -0
  56. package/dist/src/frontend/state.js +28 -0
  57. package/dist/src/frontend/utils.js +21 -0
  58. package/dist/src/frontend/vendor/wordcloud2.js +1187 -0
  59. package/dist/src/frontend/wordcloud.js +693 -0
  60. package/dist/src/lib/config.d.ts +17 -0
  61. package/dist/src/lib/config.d.ts.map +1 -0
  62. package/dist/src/lib/config.js +79 -0
  63. package/dist/src/lib/config.js.map +1 -0
  64. package/dist/src/lib/parser.d.ts +11 -0
  65. package/dist/src/lib/parser.d.ts.map +1 -0
  66. package/dist/src/lib/parser.js +111 -0
  67. package/dist/src/lib/parser.js.map +1 -0
  68. package/dist/src/mcp/server.d.ts +3 -0
  69. package/dist/src/mcp/server.d.ts.map +1 -0
  70. package/dist/src/mcp/server.js +986 -0
  71. package/dist/src/mcp/server.js.map +1 -0
  72. package/dist/src/mcp/tools/diagrams.d.ts +44 -0
  73. package/dist/src/mcp/tools/diagrams.d.ts.map +1 -0
  74. package/dist/src/mcp/tools/diagrams.js +245 -0
  75. package/dist/src/mcp/tools/diagrams.js.map +1 -0
  76. package/dist/src/mcp/tools/documents.d.ts +26 -0
  77. package/dist/src/mcp/tools/documents.d.ts.map +1 -0
  78. package/dist/src/mcp/tools/documents.js +127 -0
  79. package/dist/src/mcp/tools/documents.js.map +1 -0
  80. package/dist/src/mcp/tools/source.d.ts +29 -0
  81. package/dist/src/mcp/tools/source.d.ts.map +1 -0
  82. package/dist/src/mcp/tools/source.js +200 -0
  83. package/dist/src/mcp/tools/source.js.map +1 -0
  84. package/dist/src/routes/annotations.d.ts +3 -0
  85. package/dist/src/routes/annotations.d.ts.map +1 -0
  86. package/dist/src/routes/annotations.js +83 -0
  87. package/dist/src/routes/annotations.js.map +1 -0
  88. package/dist/src/routes/browse.d.ts +3 -0
  89. package/dist/src/routes/browse.d.ts.map +1 -0
  90. package/dist/src/routes/browse.js +75 -0
  91. package/dist/src/routes/browse.js.map +1 -0
  92. package/dist/src/routes/config.d.ts +3 -0
  93. package/dist/src/routes/config.d.ts.map +1 -0
  94. package/dist/src/routes/config.js +97 -0
  95. package/dist/src/routes/config.js.map +1 -0
  96. package/dist/src/routes/diagrams.d.ts +3 -0
  97. package/dist/src/routes/diagrams.d.ts.map +1 -0
  98. package/dist/src/routes/diagrams.js +69 -0
  99. package/dist/src/routes/diagrams.js.map +1 -0
  100. package/dist/src/routes/documents.d.ts +8 -0
  101. package/dist/src/routes/documents.d.ts.map +1 -0
  102. package/dist/src/routes/documents.js +332 -0
  103. package/dist/src/routes/documents.js.map +1 -0
  104. package/dist/src/routes/export.d.ts +3 -0
  105. package/dist/src/routes/export.d.ts.map +1 -0
  106. package/dist/src/routes/export.js +277 -0
  107. package/dist/src/routes/export.js.map +1 -0
  108. package/dist/src/routes/images.d.ts +3 -0
  109. package/dist/src/routes/images.d.ts.map +1 -0
  110. package/dist/src/routes/images.js +49 -0
  111. package/dist/src/routes/images.js.map +1 -0
  112. package/dist/src/routes/wordcloud.d.ts +3 -0
  113. package/dist/src/routes/wordcloud.d.ts.map +1 -0
  114. package/dist/src/routes/wordcloud.js +95 -0
  115. package/dist/src/routes/wordcloud.js.map +1 -0
  116. package/dist/src/server.d.ts +7 -0
  117. package/dist/src/server.d.ts.map +1 -0
  118. package/dist/src/server.js +76 -0
  119. package/dist/src/server.js.map +1 -0
  120. package/dist/starting-doc/.annotations.json +3 -0
  121. package/dist/starting-doc/.diagrams.json +1884 -0
  122. package/dist/starting-doc/.living-doc.json +39 -0
  123. package/dist/starting-doc/1_tutorial/2026_04_11_13_25_[General]_crer_vos_dossiers.md +16 -0
  124. package/dist/starting-doc/1_tutorial/2026_04_11_18_58_[General]_creer_un_document_dans_un_dossier.md +9 -0
  125. package/dist/starting-doc/1_tutorial/2026_04_12_09_00_[General]_editer_et_sauvegarder.md +39 -0
  126. package/dist/starting-doc/1_tutorial/2026_04_12_10_00_[General]_utiliser_les_snippets.md +71 -0
  127. package/dist/starting-doc/2026_04_08_20_52_[General]_welcome.md +17 -0
  128. package/dist/starting-doc/2026_04_11_12_55_[General]_premiers_pas.md +271 -0
  129. package/dist/starting-doc/2_guide/2026_04_08_00_04_[DOCUMENT]_utilisation_des_images_plein_ecran_lien_clickable.md +40 -0
  130. package/dist/starting-doc/2_guide/2026_04_08_23_38_[Configuration]_demarrage_de_living_documentation.md +32 -0
  131. package/dist/starting-doc/2_guide/2026_04_09_09_00_[NAVIGATION]_recherche_plein_texte.md +65 -0
  132. package/dist/starting-doc/2_guide/2026_04_09_10_00_[EXPORT]_exporter_en_pdf.md +43 -0
  133. package/dist/starting-doc/2_guide/2026_04_09_11_00_[Configuration]_configurer_le_panneau_admin.md +55 -0
  134. package/dist/starting-doc/2_guide/2026_04_09_12_00_[Configuration]_extra_files.md +68 -0
  135. package/dist/starting-doc/2_guide/2026_04_09_13_00_[WORDCLOUD]_word_cloud.md +54 -0
  136. package/dist/starting-doc/2_guide/2026_04_09_14_00_[DIAGRAM]_creer_et_lier_un_diagramme.md +77 -0
  137. package/dist/starting-doc/3_concept/2026_04_08_20_58_[DOCUMENTING]_ADRS.md +20 -0
  138. package/dist/starting-doc/3_concept/2026_04_08_22_15_[DOCUMENTING]_living_documentation.md +17 -0
  139. package/dist/starting-doc/3_concept/2026_04_08_22_46_[METHODOLOGY]_diataxis_architecture_du_contenu.md +16 -0
  140. package/dist/starting-doc/4_reference/2026_04_08_23_14_[FUNDAMENTALS]_the_living_documentation_tool.md +41 -0
  141. package/dist/starting-doc/4_reference/2026_04_09_01_00_[REFERENCE]_raccourcis_clavier.md +61 -0
  142. package/dist/starting-doc/4_reference/2026_04_09_02_00_[REFERENCE]_tokens_pattern_nommage.md +75 -0
  143. package/dist/starting-doc/4_reference/2026_04_09_03_00_[REFERENCE]_types_de_snippets.md +68 -0
  144. package/dist/starting-doc/4_reference/2026_04_11_17_31_[FUNDAMENTALS]_architecturer_une_documentation.md +12 -0
  145. package/dist/starting-doc/4_reference/2026_04_12_14_07_[FUNDAMENTALS]_dossiers_et_catgories.md +89 -0
  146. package/dist/starting-doc/images/admin_screenshot.png +0 -0
  147. package/dist/starting-doc/images/ajout-document.png +0 -0
  148. package/dist/starting-doc/images/ajouter-document-categorie.png +0 -0
  149. package/dist/starting-doc/images/ajouter_un_document_dans_un_dossier.png +0 -0
  150. package/dist/starting-doc/images/architecturer_une_documentation_reference.png +0 -0
  151. package/dist/starting-doc/images/cr_er_un_document.png +0 -0
  152. package/dist/starting-doc/images/creation-nouveau-dossier.png +0 -0
  153. package/dist/starting-doc/images/creer-document-context-engineering.png +0 -0
  154. package/dist/starting-doc/images/creer-dossier-only-tutoriel.png +0 -0
  155. package/dist/starting-doc/images/creer-dossier-tutoriel.png +0 -0
  156. package/dist/starting-doc/images/creer-dossiers-done.png +0 -0
  157. package/dist/starting-doc/images/creer-un-document.png +0 -0
  158. package/dist/starting-doc/images/creer-vos-dossiers-tutoriel.png +0 -0
  159. package/dist/starting-doc/images/creer-vos-dossiers.png +0 -0
  160. package/dist/starting-doc/images/decouverte_adrs.png +0 -0
  161. package/dist/starting-doc/images/diataxis.png +0 -0
  162. package/dist/starting-doc/images/diataxis_callout.png +0 -0
  163. package/dist/starting-doc/images/document-cree.png +0 -0
  164. package/dist/starting-doc/images/liens_snippets.png +0 -0
  165. package/dist/starting-doc/images/living_documentation.png +0 -0
  166. package/dist/starting-doc/images/npm_logo.png +0 -0
  167. package/dist/starting-doc/images/popup-creer-document.png +0 -0
  168. package/dist/starting-doc/images/popup-creer-dossier.png +0 -0
  169. package/dist/starting-doc/images/popup-dossier-cree.png +0 -0
  170. package/dist/starting-doc/images/quatre-dossiers-crees.png +0 -0
  171. package/dist/starting-doc/images/screenshot-living-doc.png +0 -0
  172. package/dist/starting-doc/images/the_living_documentation_tool.png +0 -0
  173. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,329 @@
1
+ # Living Documentation
2
+
3
+ A CLI tool that serves a local Markdown documentation viewer in your browser.
4
+ `NASHTAZ DOO`
5
+ No cloud, no database, no build step — just point it at a folder where you add your project's folder documentation composed of `.md` files (ADR : Architecture Decision Records, generally).
6
+
7
+ ![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)
8
+ ![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)
9
+ ![License](https://img.shields.io/badge/License-AGPL--3.0-blue)
10
+
11
+ ## Features
12
+
13
+ - **Sidebar** grouped by folder → category, sorted alphabetically; **General** always first
14
+ [![README Diagrams](./images/readme-sidebar.png)](/diagram?id=d1775399110713)
15
+
16
+ - **Categories Sections and General section** — Categories are extracted from the fileName pattern of your Markdown documents (that may be Architecture Decision Records ADRs).
17
+ ExtraFiles (added in the admin section) are always first, always expanded in a `GENERAL Section` that holds uncategorized docs and extra files
18
+ [![README Diagrams](./images/readme-filename-pattern.png)](/diagram?id=d1775399110713)
19
+
20
+ - **Recursive folder scanning** — subdirectories are scanned automatically; each directory level becomes a collapsible folder in the sidebar, nested above the category groups
21
+
22
+ - **Extra files** — You can add custom ExtraFiles to your documentation that are outside the docs folder (e.g. `README.md`, `CLAUDE.md`) in the `Admin` Page
23
+ [![README Diagrams](./images/readme-extra-files.png)](/diagram?id=d1775399110713)
24
+
25
+ - **Dark mode** — follows system preference, manually toggleable
26
+ - **Syntax highlighting** — always dark, high-contrast code blocks
27
+ [![README Diagrams](./images/readme-code-blocks.png)](/diagram?id=d1775399110713)
28
+
29
+ - **Full-text search** — instant filter + server-side content search. Returns all the files containing searched occurences, and for each file lists all the occurences, highlight them, and visit them.
30
+ [![README Diagrams](./images/readme-intelligent-search-demo.png)](/diagram?id=d1775399110713)
31
+
32
+ - **Inline editing** — edit any document directly in the browser, saves to disk instantly
33
+ - **Image paste** — paste an image from clipboard in the editor; auto-uploaded and inserted as Markdown
34
+ - **Snippet inserter** — click **🧩 Snippets** while editing to insert pre-built Markdown constructs at the cursor position:
35
+ - *Simple snippets*: collapsible block (`<details>`), link, link to another document, anchor link, anchor link in another document, numbered list (3 levels), bullet list (3 levels), code block, blockquote, horizontal separator, image
36
+ - *Complex snippets*: **table editor** (dynamic rows/columns grid, generates aligned Markdown table) and **tree editor** (indentation-based ASCII tree, generates a `text` code block with `├──` / `└──` connectors)
37
+ - **Detection mode**: select an existing snippet in the editor before opening the panel — the type is detected automatically and all fields are pre-filled for editing; an informational message is shown when the selection is recognised (green) or unrecognised (orange)
38
+ - **Anchor navigation** — links to headings within a document (e.g. `[See section](#my-heading)`) scroll to the correct position after async rendering; heading IDs are generated automatically from their text content
39
+ - **Export to PDF** — Export the markdown as a PDF document
40
+ - **Diagram editor** — built-in canvas diagram editor; deep-link to any diagram in the C4 Model Style; Paste images into diagrams; Export PNG From Images; And Many more features ...
41
+
42
+ - **Admin panel** — configure title, theme, filename pattern, and extra files in the browser
43
+ - **Word Cloud** — visualise the dominant vocabulary of any folder on disk; supports `.md`, `.ts`, `.java`, `.kt`, `.py`, `.go`, `.rs`, `.cs`, `.swift`, `.rb`, `.html`, `.css`, `.yml`, `.json` and more; stop words filtered per language
44
+
45
+ ---
46
+
47
+ ## Quick start
48
+
49
+ ```bash
50
+ npx living-documentation ./path/to/docs
51
+ ```
52
+
53
+ Then open [http://localhost:4321](http://localhost:4321).
54
+
55
+ ---
56
+
57
+ ## Installation
58
+
59
+ ### npx (no install)
60
+
61
+ ```bash
62
+ npx living-documentation ./docs
63
+ ```
64
+
65
+ ### Global install
66
+
67
+ ```bash
68
+ npm install -g living-documentation
69
+ living-documentation ./docs
70
+ ```
71
+
72
+ ### Local development
73
+
74
+ ```bash
75
+ git clone <repo>
76
+ cd living-documentation
77
+ npm install
78
+ npm run dev -- ./docs # nodemon + ts-node, auto-restarts on changes
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Usage
84
+
85
+ ```
86
+ living-documentation [folder] [options]
87
+
88
+ Arguments:
89
+ folder Path to the documentation folder (default: ".")
90
+
91
+ Options:
92
+ -p, --port <number> Port to listen on (default: 4321)
93
+ -o, --open Open browser automatically
94
+ -V, --version Print version
95
+ -h, --help Show help
96
+ ```
97
+
98
+ **Examples:**
99
+
100
+ ```bash
101
+ living-documentation ./docs
102
+ living-documentation ./docs --port 4000 --open # override port
103
+ living-documentation . # current folder
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Filename convention
109
+
110
+ Documents are parsed using this default pattern:
111
+
112
+ ```
113
+ YYYY_MM_DD_HH_mm_[Category]_title_words.md
114
+ ```
115
+
116
+ | Part | Example | Parsed as |
117
+ | ----------------- | -------------------- | ------------------------------ |
118
+ | `2024_01_15` | `2024_01_15` | Date → Jan 15, 2024 |
119
+ | `09_30` | `09_30` | Time → 09:30 |
120
+ | `[DevOps]` | `[DevOps]` | Category → DevOps |
121
+ | `deploy_pipeline` | `deploy_pipeline` | Title → Deploy Pipeline |
122
+
123
+ **Full example:**
124
+
125
+ ```
126
+ 2024_01_15_09_30_[DevOps]_deploy_pipeline.md
127
+ 2024_03_20_14_45_[Frontend]_react_hooks_guide.md
128
+ 2023_11_03_11_00_[Backend]_api_versioning_strategy.md
129
+ ```
130
+
131
+ Files that don't match the pattern are still shown — they appear under **General** with the filename as the title.
132
+
133
+ ### Subdirectories
134
+
135
+ The docs folder is scanned **recursively**. Each subdirectory level becomes a collapsible **folder** in the sidebar, nested above the category groups extracted from filenames.
136
+
137
+ - The `[Category]` tag in the filename is always the category, regardless of which folder the file lives in.
138
+ - Files without a `[Category]` tag fall into **General**.
139
+ - Subdirectory names become the folder labels in the sidebar (title-cased).
140
+ - Deep nesting is supported: `adrs/test/file.md` → folder **Adrs** > subfolder **Test** > category > doc.
141
+
142
+ ```
143
+ docs/
144
+ ├── 2024_01_15_09_30_[DevOps]_deploy.md → (root) category: DevOps
145
+ ├── adrs/
146
+ │ ├── my-decision.md → folder: Adrs / category: General
147
+ │ ├── 2024_03_01_10_00_[Architecture]_eventsourcing.md → folder: Adrs / category: Architecture
148
+ │ └── test/
149
+ │ └── 2024_05_01_11_15_[Architecture]_saga.md → folder: Adrs > Test / category: Architecture
150
+ └── guides/
151
+ └── 2024_06_01_14_00_[Onboarding]_setup.md → folder: Guides / category: Onboarding
152
+ ```
153
+
154
+ **Sidebar rendering order at each level:** General first → subfolders (alphabetical) → other categories (alphabetical).
155
+
156
+ #### Controlling folder order with a numeric prefix
157
+
158
+ Folders are sorted alphabetically, which means you can control their order by prefixing the directory name with a number followed by `_`:
159
+
160
+ ```
161
+ docs/
162
+ ├── 1_TUTORIAL/
163
+ ├── 2_REFERENCE/
164
+ └── 3_ADVANCED/
165
+ ```
166
+
167
+ The prefix is **hidden in the UI** — the sidebar shows `TUTORIAL`, `REFERENCE`, `ADVANCED` — but the full name (e.g. `1_TUTORIAL`) is visible in the tooltip on hover. Breadcrumb pills on articles follow the same rule.
168
+
169
+ **Article header** shows one violet pill per folder segment, then a blue pill for the category.
170
+
171
+ The pattern is **configurable** in the Admin panel. Token order is respected — `[Category]_YYYY_MM_DD_HH_mm_title` is valid. `[Category]` must appear exactly once.
172
+
173
+ ---
174
+
175
+ ## Config file
176
+
177
+ A `.living-doc.json` file is created automatically in your docs folder on first run:
178
+
179
+ ```json
180
+ {
181
+ "docsFolder": "/absolute/path/to/docs",
182
+ "filenamePattern": "YYYY_MM_DD_HH_mm_[Category]_title",
183
+ "title": "Living Documentation",
184
+ "theme": "system",
185
+ "port": 4321,
186
+ "extraFiles": []
187
+ }
188
+ ```
189
+
190
+ You can edit it manually or use the **Admin panel** at [http://localhost:4321/admin](http://localhost:4321/admin).
191
+
192
+ ### Extra files
193
+
194
+ The `extraFiles` field accepts an ordered list of absolute paths to `.md` files located **outside** the docs folder. These files always appear in the **General** section, before regular General documents, in the order defined.
195
+
196
+ ```json
197
+ {
198
+ "extraFiles": [
199
+ "/path/to/project/README.md",
200
+ "/path/to/project/CLAUDE.md"
201
+ ]
202
+ }
203
+ ```
204
+
205
+ Use the Admin panel's **General — Extra Files** section to browse the filesystem and manage this list without editing the config manually.
206
+
207
+ ---
208
+
209
+ ## Project structure
210
+
211
+ ```
212
+ living-documentation/
213
+ ├── bin/
214
+ │ └── cli.ts CLI entry point
215
+ ├── src/
216
+ │ ├── server.ts Express app
217
+ │ ├── routes/
218
+ │ │ ├── documents.ts Documents API (list, search, read, write)
219
+ │ │ ├── config.ts Config API
220
+ │ │ ├── browse.ts Filesystem browser API
221
+ │ │ └── images.ts Image upload API
222
+ │ ├── lib/
223
+ │ │ ├── parser.ts Filename parser
224
+ │ │ └── config.ts Config management
225
+ │ └── frontend/
226
+ │ ├── index.html Main viewer
227
+ │ └── admin.html Admin panel
228
+ ├── scripts/
229
+ │ └── copy-assets.js Build helper (copies HTML to dist/)
230
+ ├── package.json
231
+ └── tsconfig.json
232
+ ```
233
+
234
+ ---
235
+
236
+ ## API reference
237
+
238
+ | Method | Endpoint | Description |
239
+ | ------ | -------------------------- | ------------------------------------------------------------------ |
240
+ | `GET` | `/api/documents` | List all documents with metadata (includes extra files) |
241
+ | `GET` | `/api/documents/:id` | Get document content + rendered HTML |
242
+ | `PUT` | `/api/documents/:id` | Save document content to disk |
243
+ | `GET` | `/api/documents/search?q=` | Full-text search |
244
+ | `GET` | `/api/config` | Read config |
245
+ | `PUT` | `/api/config` | Update config (`title`, `theme`, `filenamePattern`, `extraFiles`) |
246
+ | `GET` | `/api/browse?path=` | List directories and `.md` files at a given filesystem path |
247
+ | `POST` | `/api/images/upload` | Upload a base64 image; saved to `DOCS_FOLDER/images/` |
248
+
249
+ ---
250
+
251
+ ## MCP server (Model Context Protocol)
252
+
253
+ Living Documentation exposes an **MCP server** over HTTP so that AI assistants (Claude Desktop, Claude Code, Cursor, etc.) can read and create documents and diagrams programmatically — without leaving your editor.
254
+
255
+ The server starts automatically alongside the Express app; no extra process is needed.
256
+
257
+ ### Endpoint
258
+
259
+ ```
260
+ POST http://localhost:4321/mcp
261
+ ```
262
+
263
+ Transport: **Streamable HTTP** (stateless — one session per request).
264
+
265
+ A `GET http://localhost:4321/mcp` returns a JSON summary of available tools for quick inspection.
266
+
267
+ ### Available tools
268
+
269
+ | Tool | Description |
270
+ |---|---|
271
+ | `list_documents` | List all documents with their id, title, category and folder |
272
+ | `read_document` | Read the raw Markdown content of a document by its id |
273
+ | `create_document` | Create a new Markdown document (filename generated from the configured pattern) |
274
+ | `list_diagrams` | List all saved diagrams with their id and title |
275
+ | `create_diagram` | Create a diagram from nodes and edges (shapes, colors, labels) |
276
+
277
+ ### Installation — Claude Desktop
278
+
279
+ Add the following to your `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`):
280
+
281
+ ```json
282
+ {
283
+ "mcpServers": {
284
+ "living-documentation": {
285
+ "type": "http",
286
+ "url": "http://localhost:4321/mcp"
287
+ }
288
+ }
289
+ }
290
+ ```
291
+
292
+ Then restart Claude Desktop. Living Documentation must be running (`npx living-documentation ./docs`) before Claude Desktop connects.
293
+
294
+ ### Installation — Claude Code
295
+
296
+ Add the MCP server to your project with:
297
+
298
+ ```bash
299
+ claude mcp add --transport http living-documentation http://localhost:4321/mcp
300
+ ```
301
+
302
+ Or add it manually to `.claude/settings.json` / `~/.claude/settings.json`:
303
+
304
+ ```json
305
+ {
306
+ "mcpServers": {
307
+ "living-documentation": {
308
+ "type": "http",
309
+ "url": "http://localhost:4321/mcp"
310
+ }
311
+ }
312
+ }
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Build
318
+
319
+ ```bash
320
+ npm run build # compiles TypeScript → dist/ and copies HTML assets
321
+ ```
322
+
323
+ The compiled package is self-contained inside `dist/`. Only `dist/` is included in the npm publish.
324
+
325
+ ---
326
+
327
+ ## License
328
+
329
+ AGPL-3.0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const server_1 = require("../src/server");
11
+ const program = new commander_1.Command();
12
+ function copyDir(src, dest) {
13
+ fs_1.default.mkdirSync(dest, { recursive: true });
14
+ for (const entry of fs_1.default.readdirSync(src)) {
15
+ const srcPath = path_1.default.join(src, entry);
16
+ const destPath = path_1.default.join(dest, entry);
17
+ if (fs_1.default.statSync(srcPath).isDirectory()) {
18
+ copyDir(srcPath, destPath);
19
+ }
20
+ else {
21
+ fs_1.default.copyFileSync(srcPath, destPath);
22
+ }
23
+ }
24
+ }
25
+ program
26
+ .name("living-documentation")
27
+ .description("Serve a local Markdown documentation viewer")
28
+ .version("1.0.0")
29
+ .argument("[folder]", "Path to documentation folder", ".")
30
+ .option("-i, --init", "Initialize a demo project")
31
+ .option("-p, --port <number>", "Port to listen on", "4321")
32
+ .option("-o, --open", "Open browser automatically")
33
+ .action(async (folder, options) => {
34
+ const docsPath = path_1.default.resolve(process.cwd(), folder);
35
+ if (!fs_1.default.existsSync(docsPath)) {
36
+ console.error(`\nError: Folder not found: ${docsPath}\n`);
37
+ process.exit(1);
38
+ }
39
+ const stat = fs_1.default.statSync(docsPath);
40
+ if (!stat.isDirectory()) {
41
+ console.error(`\nError: Not a directory: ${docsPath}\n`);
42
+ process.exit(1);
43
+ }
44
+ if (options.init) {
45
+ const existing = fs_1.default.readdirSync(docsPath);
46
+ if (existing.length > 0) {
47
+ console.error(`\nError: Folder is not empty: ${docsPath}\n`);
48
+ process.exit(1);
49
+ }
50
+ const startingDocPath = path_1.default.join(__dirname, "..", "starting-doc");
51
+ copyDir(startingDocPath, docsPath);
52
+ console.log(`\nInitialized demo project in ${docsPath}\n`);
53
+ }
54
+ const port = parseInt(options.port, 10);
55
+ if (isNaN(port) || port < 1 || port > 65535) {
56
+ console.error("\nError: Invalid port number\n");
57
+ process.exit(1);
58
+ }
59
+ await (0, server_1.startServer)({ docsPath, port, openBrowser: options.open ?? false });
60
+ });
61
+ program.parse();
62
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,gDAAwB;AACxB,4CAAoB;AACpB,0CAA4C;AAE5C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,SAAS,OAAO,CAAC,GAAW,EAAE,IAAY;IACxC,YAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,YAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IA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