living-docs-kit 0.1.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 (33) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +85 -0
  3. package/agents/docs-reviewer.md +33 -0
  4. package/agents/docs-writer.md +31 -0
  5. package/bin/cli.mjs +68 -0
  6. package/package.json +21 -0
  7. package/skills/docs-design/SKILL.md +91 -0
  8. package/skills/docs-design/references/theme-schema.md +108 -0
  9. package/skills/docs-guide/SKILL.md +83 -0
  10. package/skills/docs-init/SKILL.md +136 -0
  11. package/skills/docs-init/assets/DOCS-GUIDE.template.md +81 -0
  12. package/skills/docs-init/assets/agents-snippet.md +7 -0
  13. package/skills/docs-init/assets/deploy-github-pages.yml +43 -0
  14. package/skills/docs-init/assets/site-template/content/index.md +4 -0
  15. package/skills/docs-init/assets/site-template/docs.config.json +36 -0
  16. package/skills/docs-init/assets/site-template/engine/assets/app.js +414 -0
  17. package/skills/docs-init/assets/site-template/engine/assets/base.css +229 -0
  18. package/skills/docs-init/assets/site-template/engine/build.mjs +432 -0
  19. package/skills/docs-init/assets/site-template/engine/check.mjs +100 -0
  20. package/skills/docs-init/assets/site-template/engine/dev.mjs +49 -0
  21. package/skills/docs-init/assets/site-template/engine/facts.mjs +157 -0
  22. package/skills/docs-init/assets/site-template/engine/i18n.mjs +99 -0
  23. package/skills/docs-init/assets/site-template/engine/lib.mjs +368 -0
  24. package/skills/docs-init/assets/site-template/engine/palette.mjs +149 -0
  25. package/skills/docs-init/assets/site-template/engine/theme-tool.mjs +201 -0
  26. package/skills/docs-init/assets/site-template/engine/vendor/mermaid.min.js +3636 -0
  27. package/skills/docs-init/assets/site-template/package.json +24 -0
  28. package/skills/docs-init/assets/site-template/themes/atlas.json +40 -0
  29. package/skills/docs-init/assets/site-template/themes/fjord.json +40 -0
  30. package/skills/docs-init/assets/site-template/themes/graphite.json +45 -0
  31. package/skills/docs-write/SKILL.md +109 -0
  32. package/skills/docs-write/references/authoring.md +125 -0
  33. package/skills/docs-write/references/page-types.md +104 -0
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: docs-init
3
+ description: Set up a human-friendly documentation website (static site with drill-down navigation, clickable diagrams, decision tables, switchable themes) for the current code project, then run the first full generation. Use whenever the user wants to create, initialize, bootstrap or start "living docs", a docs site, a documentation website or a readable overview of their codebase for people, or wants to upgrade an existing docs-site engine. Asks for the design (existing website, palette image, preset or description), drafts the documentation guide, shows it for approval, and only then generates content.
4
+ ---
5
+
6
+ # docs-init
7
+
8
+ Creates `docs-site/` (or another folder the user picks) inside the project, gives it a design, writes the documentation guide `DOCS-GUIDE.md` together with the user, and runs the initial generation.
9
+
10
+ This skill is interactive: run it in the main conversation, never inside a subagent. Talk to the user in the language they use with you; the site and the guide default to English unless the user chooses another documentation language.
11
+
12
+ `<skill-dir>` below means the folder that contains this SKILL.md. The sibling skills live next to it: `<skill-dir>/../docs-design`, `<skill-dir>/../docs-guide`, `<skill-dir>/../docs-write`.
13
+
14
+ ## The finished layout
15
+
16
+ ```
17
+ <project>/docs-site/
18
+ docs.config.json site settings: title, default theme, code links, limits, state
19
+ DOCS-GUIDE.md what to document and how (owned by docs-guide)
20
+ content/ the pages (Markdown + frontmatter), written by docs-write
21
+ themes/ one JSON file per theme (owned by docs-design)
22
+ engine/ build, dev server, checker, facts, theme and palette tools; never edit per project
23
+ dist/ built site (git-ignored)
24
+ ```
25
+
26
+ ## Step 0 — Preconditions and existing sites
27
+
28
+ 1. Run `node -v`. Node 20 or newer is required; if it is missing or older, tell the user and stop.
29
+ 2. Find the project root: the git root if there is one (`git rev-parse --show-toplevel`), else the current folder.
30
+ 3. Look for an existing site: any `docs.config.json` next to an `engine/` folder (check `docs-site/` first, then search, skipping `node_modules`). If one exists, ask what to do:
31
+ - **Continue**: if `state.guideApproved` is false, resume at the step that is not done yet (design → guide → generation).
32
+ - **Upgrade the engine**: copy `<skill-dir>/assets/site-template/engine/` over the site's `engine/`, merge `scripts` and `dependencies` from the template `package.json`, run `npm install`, build, and stop. Content, themes, config and guide stay untouched.
33
+ - **New site in another folder**, or **cancel**.
34
+
35
+ ## Step 1 — Basics
36
+
37
+ Ask these together in one message (use the structured question tool if the client has one) and propose defaults so the user can simply confirm:
38
+
39
+ - Site folder: `docs-site`.
40
+ - Site title: the project name from the main manifest (`package.json`, `pyproject.toml`, …) or the folder name.
41
+ - Documentation language: English.
42
+ - Editor for code links: `cursor` if the user works in Cursor, `vscode` for VS Code, `none` otherwise.
43
+
44
+ ## Step 2 — Design (always ask)
45
+
46
+ Ask which design the site should use. Offer exactly these options:
47
+
48
+ 1. **An existing website**: the user gives a URL; the site takes its colours and fonts.
49
+ 2. **An image with a palette**: a link or a local file (a palette, a screenshot, a brand sheet).
50
+ 3. **One of the included themes**: Fjord (light, very readable sans-serif), Graphite (dark, amber accent), Atlas (light, serif).
51
+ 4. **A description in words**, for example "calm, dark blue, technical, compact".
52
+
53
+ Also ask whether they want a light theme, a dark theme, or both. Carry out the choice in Step 4, following docs-design.
54
+
55
+ ## Step 3 — Create the site
56
+
57
+ 1. Copy `<skill-dir>/assets/site-template/` to `<project>/<folder>/`.
58
+ 2. In `docs.config.json` set:
59
+ - `id` to a slug of the title;
60
+ - `title`;
61
+ - `uiLanguage` to `en`, or to `ro` when the documentation language is Romanian;
62
+ - `codeLinks.editor`.
63
+ Set `projectRoot` to the relative path from the site folder to the project root (`..` for `docs-site/`).
64
+ 3. If `git remote get-url origin` points to GitHub or GitLab, set `codeLinks.webBase` to the blob URL of the default branch (e.g. `https://github.com/org/repo/blob/main/`) and `codeLinks.mode` to `both`, so code links also work when the site is hosted.
65
+ 4. Replace `__PROJECT_NAME__` in `content/index.md`.
66
+ 5. Run `npm install` inside the site folder.
67
+
68
+ ## Step 4 — Apply the design
69
+
70
+ Read `<skill-dir>/../docs-design/SKILL.md` and follow its "Create a theme" procedure for the user's choice.
71
+
72
+ - For an included theme, just set it as default: `node engine/theme-tool.mjs set-default <id>`.
73
+ - Keep the other presets unless the user wants only their own theme.
74
+ - The result must be at least one valid theme set as `defaultTheme` (`node engine/theme-tool.mjs validate` passes).
75
+
76
+ ## Step 5 — Understand the project
77
+
78
+ Build a factual picture before writing the guide. Delegate the reading to an exploration subagent if the client has one.
79
+
80
+ 1. Run `node engine/facts.mjs` in the site folder. It returns:
81
+ - languages, structure and manifests;
82
+ - entry points and tests;
83
+ - existing README/AGENTS files.
84
+ 2. Read the existing READMEs (they are often written for AI; mine them for facts, not style), the manifests, the entry points and the largest source folders.
85
+ 3. Identify:
86
+ - the main modules;
87
+ - the 3–8 most important user-facing flows;
88
+ - the business rules and the entities with states;
89
+ - external systems, the data storage, and the obvious edge cases (validation, errors, limits, concurrency, money, time zones).
90
+
91
+ ## Step 6 — Draft the guide, show it, iterate
92
+
93
+ 1. Copy `<skill-dir>/assets/DOCS-GUIDE.template.md` to `<site>/DOCS-GUIDE.md`. If the documentation language is not English, translate the whole guide into that language, keeping the section structure.
94
+ 2. Fill the placeholders:
95
+ - `{{PROJECT_NAME}}`, `{{LANGUAGE}}`, `{{DATE}}` (today).
96
+ - `{{AUDIENCE}}`: default "a developer who knows the stack but not this project, and the owner returning after a few weeks away".
97
+ - `{{DATA_SECTION}}`: `[x]` if the project stores data, otherwise `[ ]`.
98
+ - `{{TOPICS}}`: 5–12 concrete bullets naming real modules, flows and rules found in Step 5, most important first.
99
+ - `{{EXCLUDES}}`: extra project-specific bullets (generated folders, vendored code, migrations…), or nothing.
100
+ - `{{PROJECT_SPECIFIC}}`: stack, domain terms with one-line meanings, conventions noticed in the code, important external systems.
101
+ - `{{UPDATE_POLICY}}`: default "after every task that changes behaviour (logic, flows, rules, edge cases, data model, public API)".
102
+ - Also disable sections that clearly do not apply, and say why in your message.
103
+ 3. Show the complete guide to the user in the chat, not only a summary, and give its path so they can edit it in the editor. Ask what to change: topics, sections, tone, depth, anything.
104
+ 4. Apply changes following `<skill-dir>/../docs-guide/SKILL.md`. Show the changed parts and ask again. Repeat until the user clearly approves ("looks good", "go", "start").
105
+ 5. Do not start generating before explicit approval. Then set `state.guideApproved` to `true` in `docs.config.json`.
106
+
107
+ ## Step 7 — Initial generation
108
+
109
+ Follow the procedure in `<skill-dir>/../docs-write/SKILL.md`, delegating to the `docs-writer` subagent when available:
110
+
111
+ 1. **Plan**: one `docs-writer` run with mode `plan`. It creates the home page, the section index pages and stub pages (frontmatter plus `<!-- stub -->`), and returns the site map.
112
+ 2. **Write**: `docs-writer` runs with mode `pages`, one per section, in parallel if the client allows it. Each gets its list of stub files.
113
+ 3. **Check**: `npm run check` in the site folder must report 0 errors. Send remaining problems back to a writer.
114
+ 4. **Review**: run the `docs-reviewer` subagent on the home page, one section overview and two detail pages. Pass its findings to a writer and fix them.
115
+ 5. **Finish**: run `node engine/facts.mjs mark`, then `npm run build`.
116
+
117
+ Without subagents, do the same steps yourself, one section at a time.
118
+
119
+ ## Step 8 — Hand over
120
+
121
+ Tell the user, briefly:
122
+
123
+ - how to view the site: `cd <folder> && npm run dev` opens a live-reloading preview at http://localhost:4321; `dist/index.html` also opens directly from disk;
124
+ - what was generated: the sections and the number of pages;
125
+ - what the checker still warns about.
126
+
127
+ Then offer two optional extras and do each only if the user says yes:
128
+
129
+ - **Keep docs up to date automatically.** Append `<skill-dir>/assets/agents-snippet.md` (with `__SITE_DIR__` replaced) to the project's `AGENTS.md` and/or `CLAUDE.md`, creating the file if needed.
130
+ - **Publish on GitHub Pages.** Copy `<skill-dir>/assets/deploy-github-pages.yml` to `.github/workflows/docs.yml` (with `__SITE_DIR__` replaced) and explain the one repository setting it needs. Mention that a public Pages site exposes the documentation; private repos need a plan that supports private Pages, or another host behind authentication.
131
+
132
+ Also mention the other skills in one line each:
133
+
134
+ - `docs-design`: add a theme or change the default;
135
+ - `docs-guide`: change what gets written;
136
+ - asking to "update the docs" runs docs-write.
@@ -0,0 +1,81 @@
1
+ # Documentation guide: {{PROJECT_NAME}}
2
+
3
+ > This file tells the agent **what** to write on the documentation site and **how**. Edit it directly, or ask the agent ("add to the guide…", "stop documenting…"), which uses the `docs-guide` skill. Rules here take precedence over the general rules of the `docs-write` skill.
4
+
5
+ ## Audience
6
+
7
+ - Primary reader: {{AUDIENCE}}
8
+ - After five minutes on the site, the reader can explain what the application does, what its main parts are, and where the important logic lives.
9
+ - The reader has not read the code. The reader can program.
10
+
11
+ ## Language and tone
12
+
13
+ - Documentation language: {{LANGUAGE}}.
14
+ - Direct and calm; short sentences; no superlatives, no marketing.
15
+ - Explain **why** something exists before **how** it works.
16
+ - Code names appear exactly as in the code, in `backticks`, linked to the code on their first mention on a page.
17
+
18
+ ## Site structure
19
+
20
+ Sections in menu order. `[x]` = enabled, `[ ]` = disabled.
21
+
22
+ - [x] **Home** (`/`): what the application is in at most 120 words, a system map (one diagram whose nodes link to the sections), and "what to know in 30 seconds" (3–5 points).
23
+ - [x] **Architecture** (`/architecture/`): from the big picture to the details: context (who uses the system, which external systems it talks to), then the large parts (apps, services, databases), then one page per important module.
24
+ - [x] **Flows** (`/flows/`): the main scenarios from the user's point of view, step by step, with a sequence diagram and a code link for each step.
25
+ - [x] **Rules and states** (`/rules/`): business rules as interactive decision tables, state machines of the main entities, and a glossary of domain terms.
26
+ - [x] **Edge cases** (`/edge-cases/`): the catalogue of special situations; each with what happens, why, where it is in the code, and which test covers it (or "not covered").
27
+ - {{DATA_SECTION}} **Data** (`/data/`): the data model (ER diagram), where data comes from and where it goes.
28
+ - [ ] **Decisions** (`/decisions/`): why an option was chosen: context, decision, rejected alternatives, consequences.
29
+ - [x] **What changed** (`/changes/`): one entry per update, written for a person ("rule X now also applies to Y"), not a list of commits.
30
+ - [ ] **Risks and technical debt** (`/risks/`): fragile, untested or hard-to-change parts.
31
+
32
+ ## Priority topics
33
+
34
+ What must be clear on the site. Proposed at initialization from the code analysis; edit freely.
35
+
36
+ {{TOPICS}}
37
+
38
+ ## Out of scope
39
+
40
+ - Generated code, third-party dependencies, trivial configuration files.
41
+ - Complete lists of files, functions or fields that change often and do not help understanding.
42
+ - Individual tests: document only which behaviour they cover and what is missing.
43
+ {{EXCLUDES}}
44
+
45
+ ## Writing rules
46
+
47
+ - Every page has a `summary` of 1–2 sentences answering "what is this and why does it matter".
48
+ - A page has at most ~600 words. Beyond that it is split into subpages and the parent becomes an overview.
49
+ - A section overview has at most ~200 words; details live in subpages.
50
+ - One paragraph, one idea. Lists only for parallel items.
51
+ - Concrete examples (real values, field names, a typical request) instead of abstract descriptions.
52
+ - Every statement about behaviour links to the code that implements it.
53
+ - Anything that could not be verified in the code is explicitly marked as unverified.
54
+ - Do not retell the code line by line; explain intent, rules and consequences.
55
+
56
+ ## Diagrams
57
+
58
+ - Home and every section page have a map diagram whose nodes link to the subpages.
59
+ - At most ~12 nodes per diagram. With more, split into levels with drill-down.
60
+ - Flows: sequence diagrams. States: state diagrams. Data: ER diagrams. Structure: flowcharts.
61
+ - Short labels (2–4 words) in the documentation language.
62
+
63
+ ## Edge cases and tests
64
+
65
+ - Edge cases appear on the page where they matter (an "Edge case" callout) and in the Edge cases catalogue.
66
+ - For each: what happens, why, where in the code, which test covers it.
67
+ - An edge case without a test is marked "not covered by tests".
68
+
69
+ ## Project specifics
70
+
71
+ {{PROJECT_SPECIFIC}}
72
+
73
+ ## Updating
74
+
75
+ - When to update: {{UPDATE_POLICY}}
76
+ - Each update changes only the affected pages and adds an entry to "What changed".
77
+ - Refactors that do not change behaviour update the code links but get no "What changed" entry.
78
+
79
+ ## Guide history
80
+
81
+ - {{DATE}}: created at initialization.
@@ -0,0 +1,7 @@
1
+ ## Living docs
2
+
3
+ This project has a human-oriented documentation site in `__SITE_DIR__/`, maintained by the `docs-*` skills.
4
+
5
+ - When a task changes behaviour (logic, flows, business rules, edge cases, data model, public API), update the docs as described in the "Actualizare" section of `__SITE_DIR__/DOCS-GUIDE.md`: delegate to the `docs-writer` subagent with mode `update`, or follow the `docs-write` skill in update mode.
6
+ - Never edit `__SITE_DIR__/engine/`. Never hand-edit `sourcesHash`, `updated` or `commit` in page frontmatter; `node engine/facts.mjs stamp` writes them.
7
+ - Preview: `cd __SITE_DIR__ && npm run dev`, or open `__SITE_DIR__/dist/index.html`.
@@ -0,0 +1,43 @@
1
+ # Publishes the documentation site to GitHub Pages on every push to the default branch.
2
+ # Copy to .github/workflows/docs.yml and replace __SITE_DIR__ with the site folder (e.g. docs-site).
3
+ # In the repository: Settings → Pages → Source: "GitHub Actions".
4
+ name: docs
5
+ on:
6
+ push:
7
+ branches: [main, master]
8
+ workflow_dispatch:
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+ concurrency:
14
+ group: pages
15
+ cancel-in-progress: true
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+ defaults:
20
+ run:
21
+ working-directory: __SITE_DIR__
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version: 20
29
+ - run: npm install --no-audit --no-fund
30
+ - run: npm run check
31
+ - run: npm run build:hosted
32
+ - uses: actions/upload-pages-artifact@v3
33
+ with:
34
+ path: __SITE_DIR__/dist
35
+ deploy:
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ environment:
39
+ name: github-pages
40
+ url: ${{ steps.deployment.outputs.page_url }}
41
+ steps:
42
+ - id: deployment
43
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: __PROJECT_NAME__
3
+ summary: The documentation has not been generated yet. Run the docs-init skill to start the initial generation.
4
+ ---
@@ -0,0 +1,36 @@
1
+ {
2
+ "id": "__SITE_ID__",
3
+ "title": "__PROJECT_NAME__",
4
+ "description": "",
5
+ "uiLanguage": "en",
6
+ "projectRoot": "..",
7
+ "defaultTheme": "fjord",
8
+ "codeLinks": {
9
+ "mode": "editor",
10
+ "editor": "cursor",
11
+ "webBase": ""
12
+ },
13
+ "limits": {
14
+ "summaryMaxChars": 280,
15
+ "pageMaxWords": 900
16
+ },
17
+ "exclude": [
18
+ "node_modules",
19
+ "dist",
20
+ "build",
21
+ "out",
22
+ ".git",
23
+ "vendor",
24
+ ".venv",
25
+ "venv",
26
+ "__pycache__",
27
+ "coverage",
28
+ ".next",
29
+ "target"
30
+ ],
31
+ "state": {
32
+ "guideApproved": false,
33
+ "lastGeneratedCommit": null,
34
+ "lastGeneratedAt": null
35
+ }
36
+ }