@guiho/xdocs 0.3.1 → 0.4.9
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 +108 -37
- package/README.md +108 -33
- package/docs/2026-07-05-xdocs-document-model.md +77 -0
- package/docs/decisions/2026-07-09-package-launcher-source-fallback.md +65 -0
- package/docs/decisions/decisions.xdocs.md +22 -0
- package/docs/docs.xdocs.md +23 -0
- package/jsr.json +1 -1
- package/library/agents.d.ts +1 -1
- package/library/agents.d.ts.map +1 -1
- package/library/agents.js +10 -6
- 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-bin.d.ts +1 -1
- package/library/guiho-xdocs-bin.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 +5 -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 +42 -22
- package/scripts/scripts.xdocs.md +10 -3
- package/scripts/xdocs-bin.ts +16 -2
- package/skills/guiho-s-xdocs/SKILL.md +133 -32
- package/skills/guiho-s-xdocs/guiho-s-xdocs.xdocs.md +26 -0
- package/skills/skills.xdocs.md +9 -4
package/library/discovery.js
CHANGED
|
@@ -2,24 +2,32 @@
|
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { readdir, stat } from 'node:fs/promises';
|
|
5
|
-
import { join, relative } from 'node:path';
|
|
5
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
6
6
|
import { parseXDocsFile } from './metadata.js';
|
|
7
|
-
|
|
7
|
+
const XDOCS_DESCRIPTOR_EXTENSION = '.xdocs.md';
|
|
8
|
+
const ROOT_XDOCS_FILENAME = 'XDOCS.md';
|
|
9
|
+
/** Scan the project for xdocs descriptor files and sibling Markdown documents. */
|
|
8
10
|
export const scanProject = async (config) => {
|
|
9
11
|
const xdocsFiles = [];
|
|
12
|
+
const markdownDocuments = [];
|
|
13
|
+
const markdownDocumentsByDirectory = new Map();
|
|
10
14
|
const allDirectories = [];
|
|
11
|
-
const coveredDirectories = new Set();
|
|
12
15
|
let totalFiles = 0;
|
|
13
|
-
await walkDirectory(config.cwd, config, async (filePath,
|
|
16
|
+
await walkDirectory(config.cwd, config, async (filePath, _dir) => {
|
|
14
17
|
totalFiles += 1;
|
|
15
|
-
if (
|
|
18
|
+
if (isXDocsDescriptorFile(filePath)) {
|
|
16
19
|
const file = await parseXDocsFile(filePath, config.cwd);
|
|
17
20
|
xdocsFiles.push(file);
|
|
18
|
-
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (isPlainMarkdownDocument(filePath)) {
|
|
24
|
+
const document = createMarkdownDocument(filePath, config.cwd);
|
|
25
|
+
markdownDocuments.push(document);
|
|
26
|
+
addMarkdownDocument(markdownDocumentsByDirectory, document.directory, document);
|
|
19
27
|
}
|
|
20
28
|
}, allDirectories);
|
|
21
29
|
// The root XDOCS.md is always recognized
|
|
22
|
-
const rootXDocs = join(config.cwd,
|
|
30
|
+
const rootXDocs = join(config.cwd, ROOT_XDOCS_FILENAME);
|
|
23
31
|
const rootAlreadyFound = xdocsFiles.some((f) => f.path === rootXDocs);
|
|
24
32
|
if (!rootAlreadyFound) {
|
|
25
33
|
try {
|
|
@@ -27,30 +35,43 @@ export const scanProject = async (config) => {
|
|
|
27
35
|
if (rootStat.isFile()) {
|
|
28
36
|
const file = await parseXDocsFile(rootXDocs, config.cwd);
|
|
29
37
|
xdocsFiles.push(file);
|
|
30
|
-
coveredDirectories.add(config.cwd);
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
catch {
|
|
34
41
|
// Root XDOCS.md does not exist, that's fine
|
|
35
42
|
}
|
|
36
43
|
}
|
|
44
|
+
enrichDescriptorFiles(xdocsFiles, markdownDocumentsByDirectory);
|
|
45
|
+
const coveredDirectories = new Set();
|
|
46
|
+
if (xdocsFiles.some((file) => file.path === rootXDocs))
|
|
47
|
+
coveredDirectories.add(config.cwd);
|
|
48
|
+
for (const file of xdocsFiles) {
|
|
49
|
+
if (file.path === rootXDocs)
|
|
50
|
+
continue;
|
|
51
|
+
if (file.valid)
|
|
52
|
+
coveredDirectories.add(file.directory);
|
|
53
|
+
}
|
|
37
54
|
const uncoveredPaths = allDirectories.filter((dir) => !coveredDirectories.has(dir));
|
|
38
55
|
return {
|
|
39
56
|
totalFiles,
|
|
40
57
|
totalDirectories: allDirectories.length,
|
|
58
|
+
totalMarkdownDocuments: markdownDocuments.length,
|
|
41
59
|
coveredDirectories: coveredDirectories.size,
|
|
42
60
|
uncoveredDirectories: uncoveredPaths.length,
|
|
43
61
|
xdocsFiles,
|
|
62
|
+
markdownDocuments,
|
|
44
63
|
uncoveredPaths,
|
|
45
64
|
};
|
|
46
65
|
};
|
|
47
|
-
/** Check if a file path
|
|
48
|
-
export const isXDocsFile = (filePath,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
/** Check if a file path is a root index or xdocs descriptor file. */
|
|
67
|
+
export const isXDocsFile = (filePath, _extensions = [XDOCS_DESCRIPTOR_EXTENSION]) => basename(filePath) === ROOT_XDOCS_FILENAME || isXDocsDescriptorFile(filePath);
|
|
68
|
+
/** Check if a file path is an xdocs module descriptor. */
|
|
69
|
+
export const isXDocsDescriptorFile = (filePath) => basename(filePath).toLowerCase().endsWith(XDOCS_DESCRIPTOR_EXTENSION);
|
|
70
|
+
/** Check if a file path is a companion Markdown document, not an xdocs descriptor. */
|
|
71
|
+
export const isPlainMarkdownDocument = (filePath) => {
|
|
72
|
+
const name = basename(filePath);
|
|
73
|
+
const lower = name.toLowerCase();
|
|
74
|
+
return lower.endsWith('.md') && lower !== 'xdocs.md' && !isXDocsDescriptorFile(filePath);
|
|
54
75
|
};
|
|
55
76
|
/** Recursively walk a directory, skipping excluded directories. */
|
|
56
77
|
const walkDirectory = async (dir, config, onFile, allDirectories) => {
|
|
@@ -76,9 +97,10 @@ const walkDirectory = async (dir, config, onFile, allDirectories) => {
|
|
|
76
97
|
};
|
|
77
98
|
/** Check if a directory name is in the exclude list. */
|
|
78
99
|
const isExcluded = (name, exclude) => exclude.includes(name) || name.startsWith('.');
|
|
79
|
-
/** Scan a specific directory (not recursive) for xdocs
|
|
100
|
+
/** Scan a specific directory (not recursive) for xdocs descriptors. */
|
|
80
101
|
export const scanDirectory = async (dirPath, config) => {
|
|
81
102
|
const files = [];
|
|
103
|
+
const markdownDocumentsByDirectory = new Map();
|
|
82
104
|
let entries;
|
|
83
105
|
try {
|
|
84
106
|
entries = await readdir(dirPath, { withFileTypes: true });
|
|
@@ -90,11 +112,17 @@ export const scanDirectory = async (dirPath, config) => {
|
|
|
90
112
|
if (!entry.isFile())
|
|
91
113
|
continue;
|
|
92
114
|
const fullPath = join(dirPath, entry.name);
|
|
93
|
-
if (
|
|
115
|
+
if (isXDocsDescriptorFile(fullPath) || isRootXDocsFile(fullPath, config.cwd)) {
|
|
94
116
|
const file = await parseXDocsFile(fullPath, config.cwd);
|
|
95
117
|
files.push(file);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (isPlainMarkdownDocument(fullPath)) {
|
|
121
|
+
const document = createMarkdownDocument(fullPath, config.cwd);
|
|
122
|
+
addMarkdownDocument(markdownDocumentsByDirectory, document.directory, document);
|
|
96
123
|
}
|
|
97
124
|
}
|
|
125
|
+
enrichDescriptorFiles(files, markdownDocumentsByDirectory);
|
|
98
126
|
return files;
|
|
99
127
|
};
|
|
100
128
|
/** List all files in a directory (non-recursive). */
|
|
@@ -116,3 +144,65 @@ export const listDirectoryFiles = async (dirPath, config) => {
|
|
|
116
144
|
}
|
|
117
145
|
return result;
|
|
118
146
|
};
|
|
147
|
+
const isRootXDocsFile = (filePath, cwd) => resolve(filePath) === resolve(cwd, ROOT_XDOCS_FILENAME);
|
|
148
|
+
const createMarkdownDocument = (filePath, cwd) => ({
|
|
149
|
+
path: filePath,
|
|
150
|
+
relativePath: relative(cwd, filePath),
|
|
151
|
+
directory: dirname(filePath),
|
|
152
|
+
name: basename(filePath),
|
|
153
|
+
});
|
|
154
|
+
const addMarkdownDocument = (documentsByDirectory, directory, document) => {
|
|
155
|
+
const documents = documentsByDirectory.get(directory) ?? [];
|
|
156
|
+
documents.push(document);
|
|
157
|
+
documentsByDirectory.set(directory, documents);
|
|
158
|
+
};
|
|
159
|
+
const enrichDescriptorFiles = (files, documentsByDirectory) => {
|
|
160
|
+
const descriptorsByDirectory = new Map();
|
|
161
|
+
for (const file of files) {
|
|
162
|
+
if (!isXDocsDescriptorFile(file.path))
|
|
163
|
+
continue;
|
|
164
|
+
const descriptors = descriptorsByDirectory.get(file.directory) ?? [];
|
|
165
|
+
descriptors.push(file);
|
|
166
|
+
descriptorsByDirectory.set(file.directory, descriptors);
|
|
167
|
+
}
|
|
168
|
+
for (const descriptors of descriptorsByDirectory.values()) {
|
|
169
|
+
if (descriptors.length <= 1)
|
|
170
|
+
continue;
|
|
171
|
+
for (const file of descriptors) {
|
|
172
|
+
file.errors.push('Multiple xdocs descriptors found in this directory. Keep exactly one named "*.xdocs.md" file per directory.');
|
|
173
|
+
file.valid = false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (const file of files) {
|
|
177
|
+
if (!isXDocsDescriptorFile(file.path))
|
|
178
|
+
continue;
|
|
179
|
+
file.documents = documentsByDirectory.get(file.directory) ?? [];
|
|
180
|
+
validateDocumentReferences(file);
|
|
181
|
+
if (file.errors.length > 0)
|
|
182
|
+
file.valid = false;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const validateDocumentReferences = (file) => {
|
|
186
|
+
if (!file.metadata)
|
|
187
|
+
return;
|
|
188
|
+
const actualDocuments = new Set(file.documents.map((document) => document.name));
|
|
189
|
+
const declaredDocuments = file.metadata.documents;
|
|
190
|
+
for (const document of file.documents) {
|
|
191
|
+
if (Object.hasOwn(declaredDocuments, document.name))
|
|
192
|
+
continue;
|
|
193
|
+
file.errors.push(`Undocumented Markdown document: "${document.name}" must be listed in the "documents" metadata map.`);
|
|
194
|
+
}
|
|
195
|
+
for (const name of Object.keys(declaredDocuments)) {
|
|
196
|
+
if (!isPlainMarkdownDocumentName(name)) {
|
|
197
|
+
file.errors.push(`Invalid document entry: "${name}" must be a sibling plain "*.md" filename, not an xdocs descriptor or path.`);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (!actualDocuments.has(name)) {
|
|
201
|
+
file.errors.push(`Missing Markdown document: "${name}" is listed in metadata but does not exist beside the descriptor.`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const isPlainMarkdownDocumentName = (name) => {
|
|
206
|
+
const lower = name.toLowerCase();
|
|
207
|
+
return !name.includes('/') && !name.includes('\\') && lower.endsWith('.md') && lower !== 'xdocs.md' && !lower.endsWith(XDOCS_DESCRIPTOR_EXTENSION);
|
|
208
|
+
};
|
package/library/flags.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { XDocsParsedArgs } from './types.js';
|
|
|
10
10
|
* - Long flags with value: `--name=write` or `--name write`
|
|
11
11
|
* - Long boolean flags: `--verbose`
|
|
12
12
|
* - Short flags: `-h`, `-v`
|
|
13
|
-
* - List values as comma-separated: `--extensions=.
|
|
13
|
+
* - List values as comma-separated: `--extensions=.xdocs.md,.custom.md`
|
|
14
14
|
* - Positional arguments after the command
|
|
15
15
|
*/
|
|
16
16
|
export declare const parseArgs: (rawArgs: string[]) => XDocsParsedArgs;
|
package/library/flags.js
CHANGED
|
@@ -24,7 +24,7 @@ const listFlags = new Set([
|
|
|
24
24
|
* - Long flags with value: `--name=write` or `--name write`
|
|
25
25
|
* - Long boolean flags: `--verbose`
|
|
26
26
|
* - Short flags: `-h`, `-v`
|
|
27
|
-
* - List values as comma-separated: `--extensions=.
|
|
27
|
+
* - List values as comma-separated: `--extensions=.xdocs.md,.custom.md`
|
|
28
28
|
* - Positional arguments after the command
|
|
29
29
|
*/
|
|
30
30
|
export const parseArgs = (rawArgs) => {
|
package/library/guiho-xdocs.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
4
|
export { XDocsError, invariant } from './errors.js';
|
|
5
|
-
export type { XDocsAgentAutomationResult, XDocsAgentSettings, XDocsAgentTool, XDocsAgentsInstructionsResult, XDocsAiMode, XDocsCliOptions, XDocsCommand, XDocsConfig, XDocsFile, XDocsFormat, XDocsMetadata, XDocsParsedArgs, XDocsPrompt, XDocsPromptName, XDocsRawConfig, XDocsScanResult, XDocsSkillInstallResult, XDocsSkillScope, XDocsTreeNode, XDocsTreeValidation, } from './types.js';
|
|
5
|
+
export type { XDocsAgentAutomationResult, XDocsAgentSettings, XDocsAgentTool, XDocsAgentsInstructionsResult, XDocsAiMode, XDocsCliOptions, XDocsCommand, XDocsConfig, XDocsFile, XDocsFormat, XDocsMarkdownDocument, XDocsMetadata, XDocsParsedArgs, XDocsPrompt, XDocsPromptName, XDocsRawConfig, XDocsScanResult, XDocsSkillInstallResult, XDocsSkillScope, XDocsTreeNode, XDocsTreeValidation, } from './types.js';
|
|
6
6
|
export { parseArgs, stringFlag, booleanFlag, listFlag } from './flags.js';
|
|
7
7
|
export { createDefaultConfigContent, DEFAULT_AGENT_SETTINGS, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeAgentSettings, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
8
|
-
export { isXDocsFile, listDirectoryFiles, scanDirectory, scanProject } from './discovery.js';
|
|
8
|
+
export { isPlainMarkdownDocument, isXDocsDescriptorFile, isXDocsFile, listDirectoryFiles, scanDirectory, scanProject } from './discovery.js';
|
|
9
9
|
export { extractFrontmatter, parseXDocsFile, validateMetadata } from './metadata.js';
|
|
10
10
|
export { buildTree, renderTree, renderTreeMarkdown, validateTree } from './tree.js';
|
|
11
11
|
export { readPackageVersion, showCommandHelp, showHelp, showVersion } from './help.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guiho-xdocs.d.ts","sourceRoot":"","sources":["../source/guiho-xdocs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGnD,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,6BAA6B,EAC7B,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAA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EAAE,MAAM,WAAW,CAAA;AAGnF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGtF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGjE,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/library/guiho-xdocs.js
CHANGED
|
@@ -8,7 +8,7 @@ export { parseArgs, stringFlag, booleanFlag, listFlag } from './flags.js';
|
|
|
8
8
|
// Config
|
|
9
9
|
export { createDefaultConfigContent, DEFAULT_AGENT_SETTINGS, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeAgentSettings, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
10
10
|
// Discovery
|
|
11
|
-
export { isXDocsFile, listDirectoryFiles, scanDirectory, scanProject } from './discovery.js';
|
|
11
|
+
export { isPlainMarkdownDocument, isXDocsDescriptorFile, isXDocsFile, listDirectoryFiles, scanDirectory, scanProject } from './discovery.js';
|
|
12
12
|
// Metadata
|
|
13
13
|
export { extractFrontmatter, parseXDocsFile, validateMetadata } from './metadata.js';
|
|
14
14
|
// Tree
|
package/library/help.js
CHANGED
|
@@ -26,12 +26,12 @@ Usage: xdocs <command> [options]
|
|
|
26
26
|
|
|
27
27
|
Commands:
|
|
28
28
|
init Initialize xdocs in a project
|
|
29
|
-
scan Scan
|
|
29
|
+
scan Scan for xdocs descriptors and Markdown documents
|
|
30
30
|
generate [path] Generate documentation for a directory or the project
|
|
31
31
|
prompt Output a ready-made prompt for AI
|
|
32
|
-
merge [path] Merge xdocs
|
|
32
|
+
merge [path] Merge xdocs descriptors from a directory into one file
|
|
33
33
|
tree Display the project hierarchy tree
|
|
34
|
-
list [path] List files
|
|
34
|
+
list [path] List documented files and documents
|
|
35
35
|
agents Install the guiho-s-xdocs skill and AGENTS.md instructions
|
|
36
36
|
|
|
37
37
|
Global Flags:
|
|
@@ -82,12 +82,13 @@ Flags:
|
|
|
82
82
|
--verbose Show detailed output
|
|
83
83
|
`.trim(),
|
|
84
84
|
scan: `
|
|
85
|
-
xdocs scan - Scan the project for xdocs
|
|
85
|
+
xdocs scan - Scan the project for xdocs descriptors
|
|
86
86
|
|
|
87
87
|
Usage: xdocs scan
|
|
88
88
|
|
|
89
|
-
Walks every directory and subdirectory (respecting exclude rules),
|
|
90
|
-
|
|
89
|
+
Walks every directory and subdirectory (respecting exclude rules), finds named
|
|
90
|
+
*.xdocs.md descriptor files, and reports plain sibling *.md documents that those
|
|
91
|
+
descriptors must list in their documents metadata.
|
|
91
92
|
|
|
92
93
|
Flags:
|
|
93
94
|
--format <format> Output format: text, json (default: text)
|
|
@@ -100,7 +101,7 @@ xdocs generate - Generate documentation
|
|
|
100
101
|
|
|
101
102
|
Usage: xdocs generate [path]
|
|
102
103
|
|
|
103
|
-
When a path is given, generates
|
|
104
|
+
When a path is given, generates documentation for that directory/module.
|
|
104
105
|
When no path is given, generates documentation for the entire project.
|
|
105
106
|
|
|
106
107
|
Flags:
|
|
@@ -122,7 +123,7 @@ a specific xdocs task. Both flag styles are supported:
|
|
|
122
123
|
|
|
123
124
|
Available prompts:
|
|
124
125
|
write How to scan a directory and write xdocs documentation
|
|
125
|
-
update How to update existing xdocs
|
|
126
|
+
update How to update existing xdocs descriptors after code changes
|
|
126
127
|
agents How to update AGENTS.md with xdocs instructions
|
|
127
128
|
generate How to generate comprehensive documentation
|
|
128
129
|
|
|
@@ -132,12 +133,12 @@ Flags:
|
|
|
132
133
|
--config <path> Path to xdocs.config.toml
|
|
133
134
|
`.trim(),
|
|
134
135
|
merge: `
|
|
135
|
-
xdocs merge - Merge xdocs
|
|
136
|
+
xdocs merge - Merge xdocs descriptors into a single file
|
|
136
137
|
|
|
137
138
|
Usage: xdocs merge [path]
|
|
138
139
|
|
|
139
|
-
Takes all xdocs files within the given directory and produces
|
|
140
|
-
one consolidated Markdown document.
|
|
140
|
+
Takes all xdocs descriptor files within the given directory and produces
|
|
141
|
+
one consolidated Markdown document, including listed companion documents.
|
|
141
142
|
|
|
142
143
|
Flags:
|
|
143
144
|
--output <path> Output file path (default: stdout)
|
|
@@ -150,7 +151,7 @@ xdocs tree - Display the project hierarchy tree
|
|
|
150
151
|
|
|
151
152
|
Usage: xdocs tree
|
|
152
153
|
|
|
153
|
-
Scans all xdocs
|
|
154
|
+
Scans all xdocs descriptors, reads their metadata, and assembles the
|
|
154
155
|
parent-child hierarchy. Shows modules only, not individual files.
|
|
155
156
|
|
|
156
157
|
Flags:
|
|
@@ -161,12 +162,12 @@ Flags:
|
|
|
161
162
|
--verbose Show detailed output
|
|
162
163
|
`.trim(),
|
|
163
164
|
list: `
|
|
164
|
-
xdocs list - List files
|
|
165
|
+
xdocs list - List documented files and documents
|
|
165
166
|
|
|
166
167
|
Usage: xdocs list [path]
|
|
167
168
|
|
|
168
|
-
Lists every file in the given scope with
|
|
169
|
-
|
|
169
|
+
Lists every source file and companion Markdown document in the given scope with
|
|
170
|
+
a short description pulled from xdocs metadata.
|
|
170
171
|
|
|
171
172
|
Flags:
|
|
172
173
|
--format <format> Output format: text, json (default: text)
|
package/library/metadata.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
4
|
import type { XDocsFile, XDocsMetadata } from './types.js';
|
|
5
|
-
/** Parse an xdocs
|
|
5
|
+
/** Parse an xdocs descriptor from disk into an XDocsFile object. */
|
|
6
6
|
export declare const parseXDocsFile: (filePath: string, cwd: string) => Promise<XDocsFile>;
|
|
7
7
|
/** Extract YAML frontmatter and body from a Markdown string. */
|
|
8
8
|
export declare const extractFrontmatter: (content: string) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../source/metadata.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1D,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../source/metadata.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1D,oEAAoE;AACpE,eAAO,MAAM,cAAc,GAAU,UAAU,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,SAAS,CA0CrF,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG;IAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAiB9F,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,OAAO,KAAG;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAwE9J,CAAA"}
|
package/library/metadata.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
|
-
import { dirname, relative } from 'node:path';
|
|
6
|
-
/** Parse an xdocs
|
|
5
|
+
import { basename, dirname, relative } from 'node:path';
|
|
6
|
+
/** Parse an xdocs descriptor from disk into an XDocsFile object. */
|
|
7
7
|
export const parseXDocsFile = async (filePath, cwd) => {
|
|
8
8
|
const content = await readFile(filePath, 'utf8');
|
|
9
9
|
const errors = [];
|
|
10
|
+
if (basename(filePath).toLowerCase() === '.xdocs.md') {
|
|
11
|
+
errors.push('Invalid xdocs descriptor filename. Use a named file such as "authentication.xdocs.md"; ".xdocs.md" is only the extension.');
|
|
12
|
+
}
|
|
10
13
|
const { frontmatter, body } = extractFrontmatter(content);
|
|
11
14
|
let metadata = null;
|
|
12
15
|
if (frontmatter) {
|
|
@@ -33,6 +36,7 @@ export const parseXDocsFile = async (filePath, cwd) => {
|
|
|
33
36
|
relativePath: relative(cwd, filePath),
|
|
34
37
|
directory: dirname(filePath),
|
|
35
38
|
metadata,
|
|
39
|
+
documents: [],
|
|
36
40
|
body,
|
|
37
41
|
valid: metadata !== null && errors.length === 0,
|
|
38
42
|
errors,
|
|
@@ -74,15 +78,24 @@ export const validateMetadata = (parsed) => {
|
|
|
74
78
|
else if (record['children'].some((child) => typeof child !== 'string')) {
|
|
75
79
|
errors.push('Invalid "children" field. All entries must be strings.');
|
|
76
80
|
}
|
|
77
|
-
if (
|
|
81
|
+
if (!isStringMap(record['files'])) {
|
|
78
82
|
errors.push('Missing or invalid "files" field. Expected an object mapping filenames to descriptions.');
|
|
79
83
|
}
|
|
84
|
+
if (!isStringMap(record['documents'])) {
|
|
85
|
+
errors.push('Missing or invalid "documents" field. Expected an object mapping sibling Markdown filenames to descriptions.');
|
|
86
|
+
}
|
|
80
87
|
if (!Array.isArray(record['tags'])) {
|
|
81
88
|
errors.push('Missing or invalid "tags" field. Expected an array of strings.');
|
|
82
89
|
}
|
|
83
90
|
else if (record['tags'].some((tag) => typeof tag !== 'string')) {
|
|
84
91
|
errors.push('Invalid "tags" field. All entries must be strings.');
|
|
85
92
|
}
|
|
93
|
+
if (!Array.isArray(record['keywords'])) {
|
|
94
|
+
errors.push('Missing or invalid "keywords" field. Expected an array of strings.');
|
|
95
|
+
}
|
|
96
|
+
else if (record['keywords'].some((keyword) => typeof keyword !== 'string')) {
|
|
97
|
+
errors.push('Invalid "keywords" field. All entries must be strings.');
|
|
98
|
+
}
|
|
86
99
|
if (!Array.isArray(record['flags'])) {
|
|
87
100
|
errors.push('Missing or invalid "flags" field. Expected an array of strings.');
|
|
88
101
|
}
|
|
@@ -101,9 +114,16 @@ export const validateMetadata = (parsed) => {
|
|
|
101
114
|
parent: record['parent'] ?? null,
|
|
102
115
|
children: record['children'],
|
|
103
116
|
files: record['files'],
|
|
117
|
+
documents: record['documents'],
|
|
104
118
|
tags: record['tags'],
|
|
119
|
+
keywords: record['keywords'],
|
|
105
120
|
flags: record['flags'],
|
|
106
121
|
status: typeof record['status'] === 'string' ? record['status'] : undefined,
|
|
107
122
|
},
|
|
108
123
|
};
|
|
109
124
|
};
|
|
125
|
+
const isStringMap = (value) => {
|
|
126
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
127
|
+
return false;
|
|
128
|
+
return Object.entries(value).every(([key, description]) => typeof key === 'string' && typeof description === 'string');
|
|
129
|
+
};
|
package/library/tree.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
4
|
import type { XDocsFile, XDocsTreeNode, XDocsTreeValidation } from './types.js';
|
|
5
|
-
/** Build a hierarchy tree from a list of xdocs
|
|
5
|
+
/** Build a hierarchy tree from a list of xdocs descriptors. */
|
|
6
6
|
export declare const buildTree: (files: XDocsFile[]) => XDocsTreeNode;
|
|
7
7
|
/** Validate tree integrity. */
|
|
8
8
|
export declare const validateTree: (files: XDocsFile[]) => XDocsTreeValidation;
|
package/library/tree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../source/tree.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAE/E
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../source/tree.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAE/E,+DAA+D;AAC/D,eAAO,MAAM,SAAS,GAAI,OAAO,SAAS,EAAE,KAAG,aA8D9C,CAAA;AAED,+BAA+B;AAC/B,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,EAAE,KAAG,mBAmCjD,CAAA;AAED,gDAAgD;AAChD,eAAO,MAAM,UAAU,GAAI,MAAM,aAAa,EAAE,eAAU,KAAG,MAe5D,CAAA;AAED,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,GAAI,MAAM,aAAa,EAAE,eAAU,KAAG,MAWpE,CAAA"}
|
package/library/tree.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*/
|
|
4
|
-
/** Build a hierarchy tree from a list of xdocs
|
|
4
|
+
/** Build a hierarchy tree from a list of xdocs descriptors. */
|
|
5
5
|
export const buildTree = (files) => {
|
|
6
6
|
const nodeMap = new Map();
|
|
7
7
|
// Create nodes for every file with valid metadata
|
|
@@ -47,7 +47,7 @@ export const buildTree = (files) => {
|
|
|
47
47
|
if (!root) {
|
|
48
48
|
root = {
|
|
49
49
|
subject: '(root)',
|
|
50
|
-
description: 'No root xdocs
|
|
50
|
+
description: 'No root xdocs descriptor found.',
|
|
51
51
|
path: null,
|
|
52
52
|
children: [...nodeMap.values()].filter((node) => !files.some((f) => f.metadata && f.metadata.children.includes(node.subject))),
|
|
53
53
|
};
|
package/library/types.d.ts
CHANGED
|
@@ -61,23 +61,33 @@ export type XDocsAgentSettings = {
|
|
|
61
61
|
autoSkillInstall: boolean;
|
|
62
62
|
skillTool: XDocsAgentTool;
|
|
63
63
|
};
|
|
64
|
-
/** YAML frontmatter metadata from an xdocs
|
|
64
|
+
/** YAML frontmatter metadata from an xdocs descriptor. */
|
|
65
65
|
export type XDocsMetadata = {
|
|
66
66
|
subject: string;
|
|
67
67
|
description: string;
|
|
68
68
|
parent: string | null;
|
|
69
69
|
children: string[];
|
|
70
70
|
files: Record<string, string>;
|
|
71
|
+
documents: Record<string, string>;
|
|
71
72
|
tags: string[];
|
|
73
|
+
keywords: string[];
|
|
72
74
|
flags: string[];
|
|
73
75
|
status?: string;
|
|
74
76
|
};
|
|
75
|
-
/** A
|
|
77
|
+
/** A sibling Markdown document listed by a module descriptor. */
|
|
78
|
+
export type XDocsMarkdownDocument = {
|
|
79
|
+
path: string;
|
|
80
|
+
relativePath: string;
|
|
81
|
+
directory: string;
|
|
82
|
+
name: string;
|
|
83
|
+
};
|
|
84
|
+
/** A discovered xdocs descriptor with its path and parsed metadata. */
|
|
76
85
|
export type XDocsFile = {
|
|
77
86
|
path: string;
|
|
78
87
|
relativePath: string;
|
|
79
88
|
directory: string;
|
|
80
89
|
metadata: XDocsMetadata | null;
|
|
90
|
+
documents: XDocsMarkdownDocument[];
|
|
81
91
|
body: string;
|
|
82
92
|
valid: boolean;
|
|
83
93
|
errors: string[];
|
|
@@ -112,9 +122,11 @@ export type XDocsCliOptions = {
|
|
|
112
122
|
export type XDocsScanResult = {
|
|
113
123
|
totalFiles: number;
|
|
114
124
|
totalDirectories: number;
|
|
125
|
+
totalMarkdownDocuments: number;
|
|
115
126
|
coveredDirectories: number;
|
|
116
127
|
uncoveredDirectories: number;
|
|
117
128
|
xdocsFiles: XDocsFile[];
|
|
129
|
+
markdownDocuments: XDocsMarkdownDocument[];
|
|
118
130
|
uncoveredPaths: string[];
|
|
119
131
|
};
|
|
120
132
|
/** Available prompt names for xdocs prompt --name. */
|
package/library/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../source/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;AAEtD,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE3C,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEzG;;;;iCAIiC;AACjC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEhD,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEhD,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,OAAO,CAAC;QAClB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAC,CAAA;IACF,EAAE,EAAE,OAAO,CAAC;QACV,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF,IAAI,EAAE,OAAO,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB,CAAC,CAAA;IACF,OAAO,EAAE,OAAO,CAAC;QACf,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF,MAAM,EAAE,OAAO,CAAC;QACd,cAAc,EAAE,OAAO,CAAA;QACvB,kBAAkB,EAAE,OAAO,CAAA;QAC3B,UAAU,EAAE,MAAM,CAAA;KACnB,CAAC,CAAA;CACH,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,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,QAAQ,CAAC,EAAE,6BAA6B,CAAA;IACxC,WAAW,CAAC,EAAE,uBAAuB,CAAA;CACtC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiho/xdocs",
|
|
3
3
|
"description": "Structured documentation system for codebases. Helps AI make sense of projects.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./library/guiho-xdocs.js",
|
|
7
7
|
"types": "./library/guiho-xdocs.d.ts",
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
"url": "https://guiho.co/cg"
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
|
+
"trustedDependencies": [
|
|
44
|
+
"@guiho/mirror"
|
|
45
|
+
],
|
|
43
46
|
"publishConfig": {
|
|
44
47
|
"access": "public"
|
|
45
48
|
},
|
|
@@ -63,8 +66,7 @@
|
|
|
63
66
|
},
|
|
64
67
|
"repository": {
|
|
65
68
|
"type": "git",
|
|
66
|
-
"url": "git+https://github.com/CGuiho/xdocs.git"
|
|
67
|
-
"directory": "xdocs"
|
|
69
|
+
"url": "git+https://github.com/CGuiho/xdocs.git"
|
|
68
70
|
},
|
|
69
71
|
"homepage": "https://github.com/CGuiho/xdocs#readme",
|
|
70
72
|
"bugs": {
|
package/prompts/agents.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agents
|
|
3
3
|
description: Update AGENTS.md with xdocs instructions for AI agents.
|
|
4
|
+
keywords:
|
|
5
|
+
- AGENTS.md
|
|
6
|
+
- agent instructions
|
|
7
|
+
- xdocs skill
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# xdocs: Update AGENTS.md
|
|
@@ -14,8 +18,11 @@ You are an AI assistant tasked with updating the AGENTS.md file to include xdocs
|
|
|
14
18
|
3. If the section exists, update it with the current xdocs configuration.
|
|
15
19
|
4. If the section does not exist, add it at the end of the file.
|
|
16
20
|
5. The xdocs section should instruct AI agents to:
|
|
17
|
-
- Read XDOCS.md and xdocs files when entering the project
|
|
21
|
+
- Read XDOCS.md and named `*.xdocs.md` descriptor files when entering the project
|
|
18
22
|
- Respect the configured AI behavior mode (prompt or auto)
|
|
19
23
|
- Use the xdocs CLI for documentation operations
|
|
20
|
-
- Maintain xdocs
|
|
24
|
+
- Maintain xdocs descriptors and companion-document metadata when modifying code
|
|
25
|
+
- Use only named `*.xdocs.md` descriptors, never nameless `.xdocs.md` files
|
|
26
|
+
- List every same-directory plain `*.md` companion document in the descriptor's `documents` metadata map
|
|
27
|
+
- Maintain `keywords` in both descriptor and companion Markdown frontmatter
|
|
21
28
|
- Follow the metadata schema for frontmatter
|
package/prompts/generate.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: generate
|
|
3
3
|
description: Generate comprehensive documentation for a domain or entire project.
|
|
4
|
+
keywords:
|
|
5
|
+
- generate documentation
|
|
6
|
+
- comprehensive docs
|
|
7
|
+
- project summary
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# xdocs: Generate Comprehensive Documentation
|
|
@@ -9,18 +13,22 @@ You are an AI assistant tasked with generating comprehensive documentation for a
|
|
|
9
13
|
|
|
10
14
|
## Instructions
|
|
11
15
|
|
|
12
|
-
1. Scan all xdocs
|
|
13
|
-
2. Read every
|
|
16
|
+
1. Scan all xdocs descriptors in the target scope (directory or project).
|
|
17
|
+
2. Read every named `*.xdocs.md` descriptor's YAML frontmatter first, then read
|
|
18
|
+
source files and same-directory plain `*.md` documents only when needed.
|
|
14
19
|
3. Build a complete understanding of:
|
|
15
20
|
- The module hierarchy
|
|
16
21
|
- The purpose of each module
|
|
17
22
|
- How modules relate to each other
|
|
18
23
|
- What each file does
|
|
24
|
+
- Which companion Markdown documents belong to each module
|
|
25
|
+
- Which keywords identify each module and companion document
|
|
19
26
|
4. Generate a single comprehensive Markdown document that includes:
|
|
20
27
|
- Project or domain overview
|
|
21
28
|
- Complete hierarchy tree
|
|
22
29
|
- Detailed description of each module
|
|
23
30
|
- File listings with descriptions
|
|
31
|
+
- Companion document listings with descriptions
|
|
24
32
|
- Cross-references between related modules
|
|
25
33
|
5. The output should be a self-contained document that fully describes the scope.
|
|
26
34
|
6. Use clear headings, consistent formatting, and concise language.
|