@guiho/xdocs 0.3.0-alpha.2 → 0.4.2
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.
- package/CHANGELOG.md +20 -0
- package/DOCS.md +70 -36
- package/README.md +57 -22
- package/docs/2026-07-05-xdocs-document-model.md +77 -0
- package/docs/docs.xdocs.md +22 -0
- package/jsr.json +1 -1
- package/library/agents.d.ts +4 -5
- package/library/agents.d.ts.map +1 -1
- package/library/agents.js +15 -14
- package/library/cli.d.ts.map +1 -1
- package/library/cli.js +5 -4
- package/library/commands/generate.d.ts.map +1 -1
- package/library/commands/generate.js +23 -1
- package/library/commands/list.d.ts.map +1 -1
- package/library/commands/list.js +14 -4
- package/library/commands/merge.d.ts.map +1 -1
- package/library/commands/merge.js +12 -1
- package/library/commands/scan.d.ts.map +1 -1
- package/library/commands/scan.js +13 -2
- package/library/config.d.ts.map +1 -1
- package/library/config.js +7 -3
- package/library/discovery.d.ts +8 -4
- package/library/discovery.d.ts.map +1 -1
- package/library/discovery.js +107 -17
- package/library/flags.d.ts +1 -1
- package/library/flags.js +1 -1
- package/library/guiho-xdocs.d.ts +2 -2
- package/library/guiho-xdocs.d.ts.map +1 -1
- package/library/guiho-xdocs.js +1 -1
- package/library/help.js +16 -15
- package/library/metadata.d.ts +1 -1
- package/library/metadata.d.ts.map +1 -1
- package/library/metadata.js +23 -3
- package/library/tree.d.ts +1 -1
- package/library/tree.d.ts.map +1 -1
- package/library/tree.js +2 -2
- package/library/types.d.ts +14 -2
- package/library/types.d.ts.map +1 -1
- package/package.json +6 -3
- package/prompts/agents.md +9 -2
- package/prompts/generate.md +10 -2
- package/prompts/prompts.xdocs.md +27 -0
- package/prompts/update.md +19 -7
- package/prompts/write.md +18 -5
- package/scripts/install-package.ts +88 -0
- package/scripts/scripts.xdocs.md +12 -5
- package/scripts/xdocs-bin.ts +33 -0
- package/skills/guiho-s-xdocs/SKILL.md +135 -34
- package/skills/guiho-s-xdocs/guiho-s-xdocs.xdocs.md +26 -0
- package/skills/skills.xdocs.md +9 -4
- package/scripts/install-native.cjs +0 -101
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# GUIHO XDocs Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.0
|
|
4
|
+
|
|
5
|
+
- Change the documentation model to one named `*.xdocs.md` descriptor per documented directory, with `XDOCS.md` reserved as the frontmatter-less repository index.
|
|
6
|
+
- Add first-class same-directory Markdown companion documents through the required `documents` metadata map, and validate descriptor/document alignment during scan.
|
|
7
|
+
- Reject nameless `.xdocs.md` descriptors, reject non-`.xdocs.md` descriptor extensions, and flag multiple descriptors in one directory.
|
|
8
|
+
- Update `scan`, `list`, `generate`, and `merge` output to surface both implementation files and companion Markdown documents.
|
|
9
|
+
- Add required `keywords` metadata to xdocs descriptors, surface descriptor keywords in scan/generate/merge output, and document companion Markdown `keywords` frontmatter.
|
|
10
|
+
- Refresh the bundled `guiho-s-xdocs` skill, prompt templates, README, architecture notes, AGENTS guidance, canonical `DOCS.md`, and package xdocs descriptors for the new model.
|
|
11
|
+
|
|
12
|
+
## 0.3.1
|
|
13
|
+
|
|
14
|
+
- Fix bare `xdocs` invocations so they install or refresh the global `guiho-s-xdocs` skill before printing help, even without `xdocs.config.toml`, and remove legacy `guiho-as-xdocs` installs for that target.
|
|
15
|
+
- Change the package-manager `xdocs` bin to a shipped Bun launcher (`scripts/xdocs-bin.ts`) that installs the native binary on first run when needed, matching GUIHO Mirror's `bun x` behavior.
|
|
16
|
+
|
|
17
|
+
## 0.3.0
|
|
18
|
+
|
|
19
|
+
- Stabilize the 0.3.0 release line, including native binary distribution, direct installers, package-manager native binary installation, and Bun-native TOML/YAML parsing.
|
|
20
|
+
- Ship the renamed `guiho-s-xdocs` agent skill with versioned frontmatter, automatic refresh from the bundled package copy, and legacy `guiho-as-xdocs` cleanup.
|
|
21
|
+
- Refresh README guidance and regression coverage for the stable release.
|
|
22
|
+
|
|
3
23
|
## 0.3.0-alpha.2
|
|
4
24
|
|
|
5
25
|
- Rename the bundled xdocs agent skill from `guiho-as-xdocs` to `guiho-s-xdocs` and add a frontmatter `version` field.
|
package/DOCS.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# GUIHO XDocs Documentation -- @guiho/xdocs
|
|
2
2
|
|
|
3
|
-
GUIHO XDocs is a deterministic CLI and TypeScript library for structured documentation of codebases. Each directory carries
|
|
3
|
+
GUIHO XDocs is a deterministic CLI and TypeScript library for structured documentation of codebases. Each documented directory carries exactly one named `*.xdocs.md` descriptor with YAML frontmatter that describes its subject, purpose, files, companion Markdown documents, and place in a parent-child hierarchy, so an AI agent (or a human) can understand a project without reading every source file.
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
|
-
source tree -> xdocs
|
|
6
|
+
source tree -> named *.xdocs.md descriptors + companion *.md documents -> tree + metadata -> AI-readable map
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
XDocs is a documentation tool, not a versioning tool. It never bumps versions or mutates `package.json` version fields. Versioning for this project is handled separately by GUIHO Mirror.
|
|
@@ -13,7 +13,7 @@ XDocs is a documentation tool, not a versioning tool. It never bumps versions or
|
|
|
13
13
|
- Package name: `@guiho/xdocs`
|
|
14
14
|
- Source/runtime during development: Bun and TypeScript (ESM)
|
|
15
15
|
- Primary release runtime: compiled native Bun binary assets
|
|
16
|
-
- Package-manager install path:
|
|
16
|
+
- Package-manager install path: the shipped Bun launcher runs `postinstall` or first-run native binary installation, then executes the native binary
|
|
17
17
|
- Package type: ESM
|
|
18
18
|
- Library entrypoint: `source/guiho-xdocs.ts`
|
|
19
19
|
- CLI entrypoint: `source/guiho-xdocs-bin.ts`
|
|
@@ -21,24 +21,25 @@ XDocs is a documentation tool, not a versioning tool. It never bumps versions or
|
|
|
21
21
|
- Standalone binary output: `bin/xdocs-*` release assets
|
|
22
22
|
- Runtime parser dependencies: none; xdocs uses Bun-native TOML and YAML parsing
|
|
23
23
|
|
|
24
|
-
The public package exposes a CLI named `xdocs` and a TypeScript API for discovering xdocs
|
|
24
|
+
The public package exposes a CLI named `xdocs` and a TypeScript API for discovering xdocs descriptors and companion Markdown documents, parsing metadata, building the hierarchy tree, generating documentation, and installing the agent skill.
|
|
25
25
|
|
|
26
26
|
## Core Model
|
|
27
27
|
|
|
28
28
|
XDocs describes a repository as a containment hierarchy of documented modules.
|
|
29
29
|
|
|
30
30
|
- Project: the repository being documented.
|
|
31
|
-
- xdocs
|
|
31
|
+
- xdocs descriptor: a named Markdown file ending in `.xdocs.md` with YAML frontmatter that documents one directory/module. A file named only `.xdocs.md` is invalid.
|
|
32
|
+
- Companion document: a same-directory plain Markdown file ending in `.md` but not `.xdocs.md` and not `XDOCS.md`. Companion documents are listed in the descriptor's `documents` metadata map.
|
|
32
33
|
- Repository root index: exactly one `XDOCS.md` per repository, at the repo root. It has **no frontmatter** and is not a tree node; it is a plain index that lists the repository's packages and applications.
|
|
33
34
|
- Package/application root: each package or application has its own root `.xdocs.md` file (with frontmatter and `parent: null`) that is the top of that package's documentation tree. `XDOCS.md` lists these package roots.
|
|
34
|
-
- Tree: a parent-child containment hierarchy (not a dependency graph) assembled from each `.xdocs.md`
|
|
35
|
+
- Tree: a parent-child containment hierarchy (not a dependency graph) assembled from each `.xdocs.md` descriptor's `subject` / `parent` / `children` fields.
|
|
35
36
|
- AI mode: how an agent should behave when documentation needs updating, configured by `[ai].mode`.
|
|
36
37
|
|
|
37
|
-
The tree is the main mental model. A module's xdocs
|
|
38
|
+
The tree is the main mental model. A module's xdocs descriptor names the module (`subject`), points up to its container (`parent`), lists the modules it contains (`children`), and lists sibling companion documents (`documents`). A package root sets `parent: null`. Reading metadata first, and companion documents only when relevant, lets an agent navigate a project cheaply.
|
|
38
39
|
|
|
39
|
-
## xdocs
|
|
40
|
+
## xdocs Descriptors and Metadata
|
|
40
41
|
|
|
41
|
-
A module's xdocs
|
|
42
|
+
A module's xdocs descriptor is Markdown with a YAML frontmatter block delimited by `---`. The body below the frontmatter is free-form Markdown. The repository's single `XDOCS.md` is the one exception: it has no frontmatter and is just an index.
|
|
42
43
|
|
|
43
44
|
```markdown
|
|
44
45
|
---
|
|
@@ -51,8 +52,14 @@ children:
|
|
|
51
52
|
files:
|
|
52
53
|
login.ts: Email/password login handler.
|
|
53
54
|
session.ts: Session creation and validation.
|
|
55
|
+
documents:
|
|
56
|
+
authentication-implementation.md: Detailed implementation notes and decisions.
|
|
54
57
|
tags:
|
|
55
58
|
- security
|
|
59
|
+
keywords:
|
|
60
|
+
- authentication
|
|
61
|
+
- login
|
|
62
|
+
- sessions
|
|
56
63
|
flags: []
|
|
57
64
|
status: stable
|
|
58
65
|
---
|
|
@@ -69,15 +76,41 @@ Frontmatter fields:
|
|
|
69
76
|
| `parent` | string \| null | `subject` of the containing module; `null` for a package/application root. |
|
|
70
77
|
| `children` | string[] | `subject`s of directly contained modules. |
|
|
71
78
|
| `files` | map<string,string> | Filename -> short description of each significant file. |
|
|
79
|
+
| `documents` | map<string,string> | Same-directory plain Markdown filename -> short description. |
|
|
72
80
|
| `tags` | string[] | Free-form classification labels. |
|
|
81
|
+
| `keywords` | string[] | Search terms and concepts agents can use to match requests. |
|
|
73
82
|
| `flags` | string[] | Behavioral markers for tools/agents. |
|
|
74
83
|
| `status` | string (optional) | Lifecycle marker, for example `stable`, `draft`, `deprecated`. |
|
|
75
84
|
|
|
76
|
-
Keep `subject` values unique across the project, keep `parent`/`children` consistent in both directions,
|
|
85
|
+
Keep `subject` values unique across the project, keep `parent`/`children` consistent in both directions, keep `files` in sync with implementation/configuration files, keep `documents` in sync with same-directory plain Markdown files, and keep `keywords` useful for search/matching.
|
|
77
86
|
|
|
78
87
|
## File Discovery and Extensions
|
|
79
88
|
|
|
80
|
-
XDocs discovers
|
|
89
|
+
XDocs discovers module descriptors by the fixed `.xdocs.md` suffix. Descriptors must be named, for example `authentication.xdocs.md`; `.xdocs.md` by itself is invalid. The root `XDOCS.md` is always recognized only as the repository index.
|
|
90
|
+
|
|
91
|
+
XDocs also discovers same-directory plain Markdown documents ending in `.md` that are not `*.xdocs.md` and not `XDOCS.md`. Each plain Markdown companion document must be listed in the containing directory descriptor's `documents` metadata map.
|
|
92
|
+
|
|
93
|
+
Ordinary companion Markdown documents should also have YAML frontmatter so agents
|
|
94
|
+
can decide whether to read the body. The standard companion fields are `name`,
|
|
95
|
+
`purpose`, `description`, `created`, `flags`, `tags`, `keywords`, and `owner`.
|
|
96
|
+
The `owner` value is the owning descriptor's `subject`.
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
---
|
|
100
|
+
name: authentication-implementation
|
|
101
|
+
purpose: Explain authentication implementation details and decisions.
|
|
102
|
+
description: Detailed notes for login, password verification, and session behavior.
|
|
103
|
+
created: 2026-07-06
|
|
104
|
+
flags: []
|
|
105
|
+
tags:
|
|
106
|
+
- security
|
|
107
|
+
keywords:
|
|
108
|
+
- authentication
|
|
109
|
+
- password verification
|
|
110
|
+
- session lifecycle
|
|
111
|
+
owner: auth
|
|
112
|
+
---
|
|
113
|
+
```
|
|
81
114
|
|
|
82
115
|
Scanning walks the project tree and skips directories listed in `[scan].exclude`. The default exclusions are `node_modules`, `.git`, `dist`, `build`, `library`, `bin`, and `bundle`.
|
|
83
116
|
|
|
@@ -93,7 +126,7 @@ curl -fsSL https://raw.githubusercontent.com/CGuiho/xdocs/main/install.sh | sh
|
|
|
93
126
|
irm https://raw.githubusercontent.com/CGuiho/xdocs/main/install.ps1 | iex
|
|
94
127
|
```
|
|
95
128
|
|
|
96
|
-
Install XDocs as a development dependency through a JavaScript package manager.
|
|
129
|
+
Install XDocs as a development dependency through a JavaScript package manager. Package-manager execution uses the shipped Bun launcher, which downloads the matching native binary during `postinstall` or on first run if the install hook did not run, then executes the native binary:
|
|
97
130
|
|
|
98
131
|
```bash
|
|
99
132
|
bun add -d @guiho/xdocs
|
|
@@ -105,7 +138,7 @@ Or with npm:
|
|
|
105
138
|
npm install -D @guiho/xdocs
|
|
106
139
|
```
|
|
107
140
|
|
|
108
|
-
Use the direct installer when you do not want a JavaScript package manager involved. Use the package-manager install when you want project-local dependency management
|
|
141
|
+
Use the direct installer when you do not want a JavaScript package manager or Bun involved at runtime. Use the package-manager install when you want project-local dependency management or `bunx` execution; the shipped Bun launcher ensures the native binary exists and delegates to it.
|
|
109
142
|
|
|
110
143
|
## Quick Start
|
|
111
144
|
|
|
@@ -169,7 +202,7 @@ Flags: `--tool <agents|claude|all>`, `--global`, `--cwd`, `--verbose`.
|
|
|
169
202
|
|
|
170
203
|
### `xdocs scan`
|
|
171
204
|
|
|
172
|
-
Walks every directory (respecting `[scan].exclude`),
|
|
205
|
+
Walks every directory (respecting `[scan].exclude`), finds named `*.xdocs.md` descriptors and sibling plain `*.md` companion documents, and reports coverage: total files, total directories, companion-document count, covered vs uncovered directories, and discovered xdocs descriptors with validity status. JSON output includes descriptor keywords. Use `--verbose` to list per-file errors, discovered companion documents, and uncovered directories.
|
|
173
206
|
|
|
174
207
|
```bash
|
|
175
208
|
xdocs scan
|
|
@@ -180,7 +213,7 @@ Flags: `--format <text|json>`, `--cwd`, `--config`, `--verbose`.
|
|
|
180
213
|
|
|
181
214
|
### `xdocs generate [path]`
|
|
182
215
|
|
|
183
|
-
Generates Markdown documentation. With no path, it produces a project-level document containing the hierarchy and a section per module. With a path, it produces a module-level document for that directory. Output goes to stdout unless `--output <path>` is given.
|
|
216
|
+
Generates Markdown documentation. With no path, it produces a project-level document containing the hierarchy and a section per module, including keywords, files, and companion documents. With a path, it produces a module-level document for that directory. Output goes to stdout unless `--output <path>` is given.
|
|
184
217
|
|
|
185
218
|
```bash
|
|
186
219
|
xdocs generate # whole project to stdout
|
|
@@ -192,7 +225,7 @@ Flags: `--output <path>`, `--cwd`, `--config`, `--verbose`.
|
|
|
192
225
|
|
|
193
226
|
### `xdocs merge [path]`
|
|
194
227
|
|
|
195
|
-
Concatenates all xdocs
|
|
228
|
+
Concatenates all xdocs descriptors within a directory into a single Markdown document, each section prefixed with a `<!-- source: ... -->` marker and including keywords plus both `files` and `documents` metadata. Output goes to stdout unless `--output <path>` is given.
|
|
196
229
|
|
|
197
230
|
```bash
|
|
198
231
|
xdocs merge ./src/domain
|
|
@@ -203,7 +236,7 @@ Flags: `--output <path>`, `--cwd`, `--config`, `--verbose`.
|
|
|
203
236
|
|
|
204
237
|
### `xdocs tree`
|
|
205
238
|
|
|
206
|
-
Scans all xdocs
|
|
239
|
+
Scans all xdocs descriptors, reads their metadata, and assembles the parent-child hierarchy (modules only, not individual files or companion documents). With `--verbose`, tree integrity warnings and errors (duplicate subjects, orphans, missing children) are printed to stderr.
|
|
207
240
|
|
|
208
241
|
```bash
|
|
209
242
|
xdocs tree
|
|
@@ -215,7 +248,7 @@ Flags: `--format <text|markdown|json>`, `--output <path>`, `--cwd`, `--config`,
|
|
|
215
248
|
|
|
216
249
|
### `xdocs list [path]`
|
|
217
250
|
|
|
218
|
-
Lists every documented file in a scope with
|
|
251
|
+
Lists every documented implementation file and companion Markdown document in a scope with short descriptions pulled from the `files` and `documents` metadata fields. JSON entries include a `kind` field with `file` or `document`.
|
|
219
252
|
|
|
220
253
|
```bash
|
|
221
254
|
xdocs list
|
|
@@ -231,8 +264,8 @@ Outputs a ready-made, self-contained instruction prompt for an AI agent. The pro
|
|
|
231
264
|
|
|
232
265
|
Available prompts:
|
|
233
266
|
|
|
234
|
-
- `write`: Scan a directory and write xdocs
|
|
235
|
-
- `update`: Update existing xdocs
|
|
267
|
+
- `write`: Scan a directory and write a named xdocs descriptor.
|
|
268
|
+
- `update`: Update existing xdocs descriptors after code or document changes.
|
|
236
269
|
- `agents`: Update `AGENTS.md` with xdocs instructions.
|
|
237
270
|
- `generate`: Generate comprehensive documentation.
|
|
238
271
|
|
|
@@ -285,7 +318,7 @@ Full configuration example:
|
|
|
285
318
|
schema = 1
|
|
286
319
|
|
|
287
320
|
[extensions]
|
|
288
|
-
supported = [".
|
|
321
|
+
supported = [".xdocs.md"]
|
|
289
322
|
|
|
290
323
|
[ai]
|
|
291
324
|
mode = "prompt"
|
|
@@ -308,7 +341,7 @@ Optional. When present, must be `1`.
|
|
|
308
341
|
|
|
309
342
|
### `[extensions]`
|
|
310
343
|
|
|
311
|
-
- `supported`:
|
|
344
|
+
- `supported`: Compatibility field for descriptor suffixes. The only supported value is `[".xdocs.md"]`; other extensions are rejected.
|
|
312
345
|
|
|
313
346
|
### `[ai]`
|
|
314
347
|
|
|
@@ -324,7 +357,7 @@ Optional. When present, must be `1`.
|
|
|
324
357
|
|
|
325
358
|
### `[agents]`
|
|
326
359
|
|
|
327
|
-
Agent settings control skill installation and the automation that runs on data commands.
|
|
360
|
+
Agent settings control skill installation and the automation that runs on bare and data commands.
|
|
328
361
|
|
|
329
362
|
- `auto_agents_md`: Keep the `AGENTS.md` xdocs section fresh on normal commands when `AGENTS.md` already exists. Default: `true`.
|
|
330
363
|
- `auto_skill_install`: Install or refresh the configured skill globally from the bundled package copy. Default: `true`.
|
|
@@ -349,22 +382,23 @@ The rule is: default to the standard target. Only write non-standard files (`.cl
|
|
|
349
382
|
|
|
350
383
|
### Automation
|
|
351
384
|
|
|
352
|
-
|
|
385
|
+
Bare `xdocs` invocations and the data commands (`scan`, `generate`, `merge`, `tree`, `list`) run agent automation before executing:
|
|
353
386
|
|
|
354
|
-
-
|
|
355
|
-
-
|
|
387
|
+
- XDocs always bootstraps the global skill with default settings when no config is present, using the standard `agents` target.
|
|
388
|
+
- When `xdocs.config.toml` is present and `auto_agents_md` is true, the xdocs section is kept fresh if `AGENTS.md` exists.
|
|
389
|
+
- When config is present and `auto_skill_install` is true, XDocs ensures the configured global skill is current from the bundled package copy, removing legacy skill names and printing a one-line notice to stderr when it installs or refreshes anything.
|
|
356
390
|
|
|
357
|
-
|
|
391
|
+
`--help` and `--version` stay read-only. `init` and `agents` do not run this automation; they manage agent files explicitly.
|
|
358
392
|
|
|
359
393
|
## AI Usage Workflow
|
|
360
394
|
|
|
361
|
-
Maintaining xdocs
|
|
395
|
+
Maintaining xdocs descriptors is an automatic responsibility for an agent working in an xdocs project, not something the user has to request. The intended workflow:
|
|
362
396
|
|
|
363
397
|
1. On entering a project, read `XDOCS.md`, run `xdocs tree`, and run `xdocs scan` to understand the structure and coverage.
|
|
364
|
-
2. On navigating to a module, read that module's xdocs
|
|
365
|
-
3. On creating a new module or subdirectory, create that directory's xdocs
|
|
366
|
-
4. On modifying a module (adding, renaming, moving, or removing files, or changing what it does), update its xdocs
|
|
367
|
-
5. `[ai].mode` governs only how the agent writes: `prompt` announces the xdocs changes then writes them; `auto` writes immediately. It never makes documentation optional. A code change is not complete until the affected xdocs
|
|
398
|
+
2. On navigating to a module, read that module's named `*.xdocs.md` descriptor frontmatter first. Use `documents` to decide which companion Markdown files to open, instead of reading every source file.
|
|
399
|
+
3. On creating a new module or subdirectory, create that directory's named xdocs descriptor (for example `authentication.xdocs.md`) describing its purpose, searchable `keywords`, its files (with their key functions/exports), its companion `documents`, and its `parent`/`children` links -- as part of the same change, without being asked.
|
|
400
|
+
4. On modifying a module (adding, renaming, moving, or removing files or sibling Markdown documents, or changing what it does), update its xdocs descriptor, companion document frontmatter, and the affected parent/child links so the documentation matches reality.
|
|
401
|
+
5. `[ai].mode` governs only how the agent writes: `prompt` announces the xdocs changes then writes them; `auto` writes immediately. It never makes documentation optional. A code change is not complete until the affected xdocs descriptors are updated and `xdocs tree` is consistent.
|
|
368
402
|
6. On request, use `xdocs generate`, `xdocs merge`, and `xdocs tree` to produce documentation artifacts.
|
|
369
403
|
|
|
370
404
|
## Prompts
|
|
@@ -420,8 +454,8 @@ The API uses the same configuration discovery and validation as the CLI.
|
|
|
420
454
|
- `source/embedded-resources.ts`: prompt, skill, and package metadata text imports used only for native binary embedding.
|
|
421
455
|
- `source/cli.ts`: argument parsing, command dispatch, config-gated automation, and process-facing error handling.
|
|
422
456
|
- `source/config.ts`: TOML discovery, schema validation, defaulting, default config generation, and agent-settings normalization.
|
|
423
|
-
- `source/discovery.ts`: filesystem scanning
|
|
424
|
-
- `source/metadata.ts`: YAML frontmatter extraction and
|
|
457
|
+
- `source/discovery.ts`: filesystem scanning, xdocs descriptor matching, companion Markdown discovery, and descriptor/document validation.
|
|
458
|
+
- `source/metadata.ts`: YAML frontmatter extraction, metadata validation, and nameless descriptor rejection.
|
|
425
459
|
- `source/tree.ts`: tree assembly, integrity checks, and rendering (text, markdown).
|
|
426
460
|
- `source/prompts.ts`: prompt loader (reads `prompts/*.md` from disk at runtime relative to `import.meta.url`).
|
|
427
461
|
- `source/help.ts`: help text and version display.
|
|
@@ -507,7 +541,7 @@ Supported release asset matrix:
|
|
|
507
541
|
|
|
508
542
|
Windows arm64 is intentionally not published until Bun's compilation support is reliable enough for this project. Unsupported platforms should use a documented manual path: install Bun and run from source, or download a compatible release asset manually.
|
|
509
543
|
|
|
510
|
-
The package-manager install path
|
|
544
|
+
The package-manager install path ships `scripts/xdocs-bin.ts` as the package `bin`. That launcher calls `scripts/install-package.ts` during first run if `vendor/xdocs` or `vendor/xdocs.exe` is missing. The install helper downloads the matching GitHub Release asset, or copies a bundled asset when present. The native binary entrypoint embeds prompt templates, the `guiho-s-xdocs` skill, and package version metadata before importing the CLI, so installed binaries do not need adjacent prompt or skill files at runtime.
|
|
511
545
|
|
|
512
546
|
## Documentation Requirement Before Publishing
|
|
513
547
|
|
|
@@ -543,7 +577,7 @@ Run `xdocs init` from the project root, or pass `--config <path>`.
|
|
|
543
577
|
|
|
544
578
|
### A directory shows as uncovered
|
|
545
579
|
|
|
546
|
-
Add
|
|
580
|
+
Add one named xdocs descriptor such as `authentication.xdocs.md` to the directory and list same-directory plain Markdown files in `documents`. Confirm the directory is not in `[scan].exclude`.
|
|
547
581
|
|
|
548
582
|
### Tree warnings or errors
|
|
549
583
|
|
package/README.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
**Structured documentation system for codebases. Helps AI make sense of projects.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**npm package:** [@guiho/xdocs](https://www.npmjs.com/package/@guiho/xdocs)
|
|
6
|
+
|
|
7
|
+
xdocs is a CLI and TypeScript library that places named `*.xdocs.md` descriptors throughout your project so that AI agents (and humans) can navigate, understand, and work within a codebase without reading every file. Each descriptor describes the directory it lives in -- its purpose, searchable keywords, its files, its companion Markdown documents, and how it fits into the project hierarchy.
|
|
6
8
|
|
|
7
9
|
```text
|
|
8
|
-
codebase -> xdocs
|
|
10
|
+
codebase -> named *.xdocs.md descriptors + companion *.md documents -> AI understands the project
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
xdocs
|
|
13
|
+
xdocs ships as compiled native binaries, a thin Bun launcher for package-manager and `bunx` execution, and a fully-typed TypeScript library.
|
|
12
14
|
|
|
13
15
|
---
|
|
14
16
|
|
|
@@ -28,7 +30,7 @@ irm https://raw.githubusercontent.com/CGuiho/xdocs/main/install.ps1 | iex
|
|
|
28
30
|
|
|
29
31
|
Set `XDOCS_VERSION=0.2.3` (or the full tag `@guiho/xdocs@0.2.3`) before running an installer to pin a specific release instead of installing the latest.
|
|
30
32
|
|
|
31
|
-
Package-manager install (convenient for JavaScript projects; downloads the matching native binary during `postinstall`,
|
|
33
|
+
Package-manager install (convenient for JavaScript projects; downloads the matching native binary during `postinstall`, or on first run if the install hook did not run):
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
36
|
npm install -D @guiho/xdocs
|
|
@@ -36,7 +38,7 @@ npm install -D @guiho/xdocs
|
|
|
36
38
|
bun add -d @guiho/xdocs
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
Native release assets are published for Linux x64/arm64, macOS x64/arm64, and Windows x64. Windows arm64 is not published yet.
|
|
41
|
+
Native release assets are published for Linux x64/arm64, macOS x64/arm64, and Windows x64. Windows arm64 is not published yet. Direct installs run without Node.js or Bun at runtime. Package-manager and `bunx` execution use a shipped Bun launcher that ensures the matching native binary is installed, then delegates to it.
|
|
40
42
|
|
|
41
43
|
### Initializing
|
|
42
44
|
|
|
@@ -55,7 +57,7 @@ This creates:
|
|
|
55
57
|
### Typical Workflow
|
|
56
58
|
|
|
57
59
|
```bash
|
|
58
|
-
# Scan the project for
|
|
60
|
+
# Scan the project for xdocs descriptors and companion Markdown documents
|
|
59
61
|
xdocs scan
|
|
60
62
|
|
|
61
63
|
# Generate documentation for a specific module
|
|
@@ -78,11 +80,11 @@ When AI works on a codebase, most of the structural knowledge lives in the head
|
|
|
78
80
|
|
|
79
81
|
### The Solution
|
|
80
82
|
|
|
81
|
-
xdocs solves this by placing
|
|
83
|
+
xdocs solves this by placing named descriptors throughout the project. Each `*.xdocs.md` descriptor describes the directory it lives in, acting as a self-contained map of that module. Instead of opening every file to understand a directory, the AI reads descriptor frontmatter first and opens listed companion documents only when relevant.
|
|
82
84
|
|
|
83
85
|
### File Format
|
|
84
86
|
|
|
85
|
-
xdocs
|
|
87
|
+
xdocs descriptors are Markdown files with YAML frontmatter and a required name before the `.xdocs.md` suffix, such as `authentication.xdocs.md`. A file named only `.xdocs.md` is invalid. Same-directory plain `*.md` files are companion documents and must be listed in `documents`.
|
|
86
88
|
|
|
87
89
|
```markdown
|
|
88
90
|
---
|
|
@@ -97,7 +99,13 @@ files:
|
|
|
97
99
|
authenticate.ts: Validates credentials and returns a session token.
|
|
98
100
|
register.ts: Creates a new user account with email verification.
|
|
99
101
|
session.ts: Manages session creation, validation, and expiration.
|
|
102
|
+
documents:
|
|
103
|
+
authentication-implementation.md: Detailed implementation notes and decisions.
|
|
100
104
|
tags: []
|
|
105
|
+
keywords:
|
|
106
|
+
- authentication
|
|
107
|
+
- sessions
|
|
108
|
+
- identity
|
|
101
109
|
flags: []
|
|
102
110
|
---
|
|
103
111
|
|
|
@@ -106,6 +114,27 @@ flags: []
|
|
|
106
114
|
The authentication module handles all identity verification flows...
|
|
107
115
|
```
|
|
108
116
|
|
|
117
|
+
Ordinary same-directory companion `.md` files should also have YAML
|
|
118
|
+
frontmatter. Use `owner` to point back to the owning descriptor `subject`, and
|
|
119
|
+
include `keywords` for search/matching:
|
|
120
|
+
|
|
121
|
+
```markdown
|
|
122
|
+
---
|
|
123
|
+
name: authentication-implementation
|
|
124
|
+
purpose: Explain authentication implementation details and decisions.
|
|
125
|
+
description: Detailed notes for login, password verification, and session behavior.
|
|
126
|
+
created: 2026-07-06
|
|
127
|
+
flags: []
|
|
128
|
+
tags:
|
|
129
|
+
- security
|
|
130
|
+
keywords:
|
|
131
|
+
- authentication
|
|
132
|
+
- password verification
|
|
133
|
+
- session lifecycle
|
|
134
|
+
owner: authentication
|
|
135
|
+
---
|
|
136
|
+
```
|
|
137
|
+
|
|
109
138
|
#### Metadata Fields
|
|
110
139
|
|
|
111
140
|
| Field | Type | Required | Description |
|
|
@@ -115,13 +144,15 @@ The authentication module handles all identity verification flows...
|
|
|
115
144
|
| `parent` | `string \| null` | Yes | The parent subject in the hierarchy. `null` for the root. |
|
|
116
145
|
| `children` | `string[]` | Yes | Child subjects (submodules) contained within this module. |
|
|
117
146
|
| `files` | `map<string, string>` | Yes | Files in this directory. Key = filename, value = description. |
|
|
147
|
+
| `documents` | `map<string, string>` | Yes | Same-directory plain Markdown documents. Key = filename, value = description. |
|
|
118
148
|
| `tags` | `string[]` | Yes | Tags for categorization and search. |
|
|
149
|
+
| `keywords` | `string[]` | Yes | Search terms and concepts agents can use to match requests. |
|
|
119
150
|
| `flags` | `string[]` | Yes | Flags for marking attributes or states. |
|
|
120
151
|
| `status` | `string` | No | Module status (e.g., `active`, `deprecated`, `experimental`). |
|
|
121
152
|
|
|
122
153
|
### The Tree
|
|
123
154
|
|
|
124
|
-
xdocs
|
|
155
|
+
xdocs descriptors form a hierarchy through their `subject`, `parent`, and `children` fields. The tree represents containment -- not dependencies -- and is computed by scanning all named `*.xdocs.md` descriptors.
|
|
125
156
|
|
|
126
157
|
```
|
|
127
158
|
project (root)
|
|
@@ -150,7 +181,7 @@ Initializes xdocs in a project. Creates the root `XDOCS.md`, the `xdocs.config.t
|
|
|
150
181
|
|
|
151
182
|
#### `xdocs scan`
|
|
152
183
|
|
|
153
|
-
Scans the project for xdocs
|
|
184
|
+
Scans the project for named `*.xdocs.md` descriptors and sibling plain Markdown companion documents. Reports descriptor validity, directory coverage, and companion-document coverage.
|
|
154
185
|
|
|
155
186
|
```bash
|
|
156
187
|
xdocs scan
|
|
@@ -174,15 +205,15 @@ xdocs generate
|
|
|
174
205
|
Outputs a ready-made prompt for AI agents. Each prompt is a self-contained instruction for a specific xdocs task. Prompts are selected by the `--name` flag, not by subcommand.
|
|
175
206
|
|
|
176
207
|
```bash
|
|
177
|
-
xdocs prompt --name=write # How to write xdocs
|
|
178
|
-
xdocs prompt --name=update # How to update existing xdocs
|
|
208
|
+
xdocs prompt --name=write # How to write a named xdocs descriptor
|
|
209
|
+
xdocs prompt --name=update # How to update existing xdocs descriptors
|
|
179
210
|
xdocs prompt --name=agents # How to update AGENTS.md
|
|
180
211
|
xdocs prompt --name=generate # How to generate comprehensive docs
|
|
181
212
|
```
|
|
182
213
|
|
|
183
214
|
#### `xdocs merge [path]`
|
|
184
215
|
|
|
185
|
-
Merges xdocs
|
|
216
|
+
Merges xdocs descriptors from a directory into a single consolidated document.
|
|
186
217
|
|
|
187
218
|
```bash
|
|
188
219
|
xdocs merge ./src/domain
|
|
@@ -199,7 +230,7 @@ xdocs tree --format markdown --output tree.md
|
|
|
199
230
|
|
|
200
231
|
#### `xdocs list [path]`
|
|
201
232
|
|
|
202
|
-
Lists files in a scope with descriptions pulled from xdocs metadata.
|
|
233
|
+
Lists implementation files and companion Markdown documents in a scope with descriptions pulled from xdocs metadata.
|
|
203
234
|
|
|
204
235
|
```bash
|
|
205
236
|
xdocs list ./src/auth
|
|
@@ -238,9 +269,8 @@ xdocs looks for configuration at `./xdocs.config.toml`, `./config/xdocs.config.t
|
|
|
238
269
|
schema = 1
|
|
239
270
|
|
|
240
271
|
[extensions]
|
|
241
|
-
#
|
|
242
|
-
|
|
243
|
-
supported = [".docs.md", ".xdocs.md"]
|
|
272
|
+
# Descriptor suffix recognized by xdocs. Only ".xdocs.md" is supported.
|
|
273
|
+
supported = [".xdocs.md"]
|
|
244
274
|
|
|
245
275
|
[ai]
|
|
246
276
|
# How the AI handles documentation updates.
|
|
@@ -259,7 +289,7 @@ exclude = ["node_modules", ".git", "dist", "build", "library", "bin", "bundle"]
|
|
|
259
289
|
name = "my-project"
|
|
260
290
|
|
|
261
291
|
[agents]
|
|
262
|
-
# Keep the xdocs section in AGENTS.md fresh on normal commands. Default: true
|
|
292
|
+
# Keep the xdocs section in AGENTS.md fresh on bare and normal commands. Default: true
|
|
263
293
|
auto_agents_md = true
|
|
264
294
|
# Install or refresh the standard skill globally from the bundled copy. Default: true
|
|
265
295
|
auto_skill_install = true
|
|
@@ -286,6 +316,8 @@ xdocs agents instructions # insert/refresh the AGENTS.md section
|
|
|
286
316
|
|
|
287
317
|
`xdocs init` runs this automatically for the standard target (`local` scope). `local` scope installs under the project; `global` installs under your home directory. The default is always the standard target -- non-standard files are written only when you ask (`--tool`) or when they are already present. Installation removes legacy `guiho-as-xdocs` skill directories and replaces `guiho-s-xdocs` when the bundled version or content differs.
|
|
288
318
|
|
|
319
|
+
A bare `xdocs` invocation and the normal data commands refresh the global skill before doing their usual work. Without `xdocs.config.toml`, xdocs uses the standard `agents` target; with config, `[agents].skill_tool` can choose the target and `[agents].auto_skill_install = false` can disable the refresh. If the legacy `guiho-as-xdocs` skill exists for that global target, xdocs removes it and writes the bundled `guiho-s-xdocs` skill.
|
|
320
|
+
|
|
289
321
|
---
|
|
290
322
|
|
|
291
323
|
## API Reference
|
|
@@ -307,16 +339,19 @@ const configOrDefaults = await loadConfigOrDefaults({ cwd: process.cwd(), format
|
|
|
307
339
|
### Discovery and Scanning
|
|
308
340
|
|
|
309
341
|
```ts
|
|
310
|
-
import { scanProject, scanDirectory, isXDocsFile } from '@guiho/xdocs'
|
|
342
|
+
import { scanProject, scanDirectory, isPlainMarkdownDocument, isXDocsDescriptorFile, isXDocsFile } from '@guiho/xdocs'
|
|
311
343
|
|
|
312
344
|
// Scan the entire project
|
|
313
345
|
const result = await scanProject(config)
|
|
314
346
|
console.log(result.totalFiles) // Total files found
|
|
315
347
|
console.log(result.xdocsFiles) // Array of XDocsFile objects
|
|
348
|
+
console.log(result.markdownDocuments) // Companion Markdown documents found
|
|
316
349
|
console.log(result.uncoveredPaths) // Directories without xdocs coverage
|
|
317
350
|
|
|
318
|
-
// Check
|
|
319
|
-
isXDocsFile('auth.xdocs.md'
|
|
351
|
+
// Check descriptor and companion document files
|
|
352
|
+
isXDocsFile('auth.xdocs.md') // true
|
|
353
|
+
isXDocsDescriptorFile('auth.xdocs.md') // true
|
|
354
|
+
isPlainMarkdownDocument('auth-notes.md') // true
|
|
320
355
|
```
|
|
321
356
|
|
|
322
357
|
### Metadata Parsing
|
|
@@ -324,7 +359,7 @@ isXDocsFile('auth.xdocs.md', ['.docs.md', '.xdocs.md']) // true
|
|
|
324
359
|
```ts
|
|
325
360
|
import { parseXDocsFile, extractFrontmatter, validateMetadata } from '@guiho/xdocs'
|
|
326
361
|
|
|
327
|
-
// Parse an xdocs
|
|
362
|
+
// Parse an xdocs descriptor from disk
|
|
328
363
|
const file = await parseXDocsFile('/path/to/auth.xdocs.md', process.cwd())
|
|
329
364
|
console.log(file.metadata?.subject) // "authentication"
|
|
330
365
|
console.log(file.metadata?.description) // "Handles user login..."
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: xdocs Document Model
|
|
3
|
+
purpose: Record the descriptor-plus-companion-document model for future xdocs implementation work.
|
|
4
|
+
description: Explains how named xdocs descriptors, root XDOCS.md, and same-directory Markdown companion documents work together for AI navigation.
|
|
5
|
+
created: 2026-07-05
|
|
6
|
+
keywords:
|
|
7
|
+
- xdocs descriptors
|
|
8
|
+
- companion documents
|
|
9
|
+
- AI navigation
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# xdocs Document Model
|
|
13
|
+
|
|
14
|
+
## Summary
|
|
15
|
+
|
|
16
|
+
xdocs now treats a directory as documented by exactly one named `*.xdocs.md`
|
|
17
|
+
descriptor. The root of a repository still uses `XDOCS.md` as a plain index with
|
|
18
|
+
no frontmatter, but normal modules use a descriptor such as
|
|
19
|
+
`authentication.xdocs.md`. A file named only `.xdocs.md` is invalid because
|
|
20
|
+
`.xdocs.md` is the extension, not the filename.
|
|
21
|
+
|
|
22
|
+
## Descriptor Metadata
|
|
23
|
+
|
|
24
|
+
The descriptor is the AI-facing map for a module. Its YAML frontmatter contains
|
|
25
|
+
the module identity, parent/child tree links, implementation files, and sibling
|
|
26
|
+
Markdown companion documents.
|
|
27
|
+
|
|
28
|
+
```yaml
|
|
29
|
+
---
|
|
30
|
+
subject: authentication
|
|
31
|
+
description: Authentication implementation and session behavior.
|
|
32
|
+
parent: backend
|
|
33
|
+
children: []
|
|
34
|
+
files:
|
|
35
|
+
login.ts: Email/password login flow.
|
|
36
|
+
session.ts: Session lifecycle and validation.
|
|
37
|
+
documents:
|
|
38
|
+
authentication-implementation.md: Detailed implementation notes and decisions.
|
|
39
|
+
tags:
|
|
40
|
+
- security
|
|
41
|
+
keywords:
|
|
42
|
+
- authentication
|
|
43
|
+
- sessions
|
|
44
|
+
- implementation notes
|
|
45
|
+
flags: []
|
|
46
|
+
status: stable
|
|
47
|
+
---
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`files` is for implementation, configuration, and asset files. `documents` is
|
|
51
|
+
only for same-directory plain `*.md` files that are not `*.xdocs.md` descriptors
|
|
52
|
+
and not `XDOCS.md`.
|
|
53
|
+
|
|
54
|
+
`keywords` is for search terms and concepts an agent can use to match a user
|
|
55
|
+
request to the right descriptor. Companion Markdown documents use the same idea
|
|
56
|
+
in their own frontmatter.
|
|
57
|
+
|
|
58
|
+
## AI Workflow
|
|
59
|
+
|
|
60
|
+
Agents should use `xdocs scan` to locate named `*.xdocs.md` descriptors, read
|
|
61
|
+
frontmatter first, and use the `documents` map to decide which companion
|
|
62
|
+
Markdown files are worth opening. When a user asks about a module, the agent can
|
|
63
|
+
find the relevant module by descriptor metadata before reading source files.
|
|
64
|
+
|
|
65
|
+
When changing a directory, an agent must update the directory descriptor so the
|
|
66
|
+
`files`, `documents`, `keywords`, `parent`, and `children` fields match disk. If a sibling
|
|
67
|
+
plain Markdown file is added, renamed, or removed, the descriptor's `documents`
|
|
68
|
+
map changes in the same unit of work.
|
|
69
|
+
|
|
70
|
+
## CLI Rules
|
|
71
|
+
|
|
72
|
+
`xdocs scan` reports descriptor coverage and validates that every sibling plain
|
|
73
|
+
Markdown file is listed in `documents`. It also marks a directory invalid when it
|
|
74
|
+
has multiple `*.xdocs.md` descriptors or a nameless `.xdocs.md` file.
|
|
75
|
+
|
|
76
|
+
`xdocs list`, `xdocs generate`, and `xdocs merge` surface both implementation
|
|
77
|
+
files and companion documents, keeping the two categories separate.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
subject: xdocs-docs
|
|
3
|
+
description: Durable project documentation for xdocs behavior, design notes, and implementation context.
|
|
4
|
+
parent: xdocs-package
|
|
5
|
+
children: []
|
|
6
|
+
files: {}
|
|
7
|
+
documents:
|
|
8
|
+
2026-07-05-xdocs-document-model.md: Defines the named descriptor plus companion Markdown document model for xdocs modules.
|
|
9
|
+
tags:
|
|
10
|
+
- documentation
|
|
11
|
+
- design
|
|
12
|
+
keywords:
|
|
13
|
+
- document model
|
|
14
|
+
- design notes
|
|
15
|
+
- companion documents
|
|
16
|
+
flags: []
|
|
17
|
+
status: stable
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
The `docs/` directory stores durable xdocs project notes. Each plain Markdown
|
|
21
|
+
document in this directory is listed in `documents` so agents can find the note
|
|
22
|
+
from descriptor metadata before opening the full document.
|