@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
|
@@ -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,MAAM,YAAY,CAAA;AAGzE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;
|
|
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,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf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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;AA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CACzB,CAAA;AAED,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;AAExE,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,eAAe,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,gEAAgE;AAChE,MAAM,MAAM,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.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./library/guiho-xdocs.js",
|
|
7
7
|
"types": "./library/guiho-xdocs.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"xdocs": "
|
|
15
|
+
"xdocs": "scripts/xdocs-bin.ts"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"README.md",
|
|
@@ -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
|
},
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
"binary": "bun build source/guiho-xdocs-native-bin.ts --compile --outfile bin/xdocs",
|
|
50
53
|
"binaries": "bun run devops/build-binaries.ts",
|
|
51
54
|
"bundle": "rm -rf bundle && bun build source/guiho-xdocs-bin.ts --outdir bundle --target node --sourcemap=linked",
|
|
52
|
-
"postinstall": "
|
|
55
|
+
"postinstall": "bun run scripts/install-package.ts",
|
|
53
56
|
"typecheck": "tsc -p . --noEmit",
|
|
54
57
|
"clean": "rm -rf .temp",
|
|
55
58
|
"clean-build": "rm -rf build library bundle bin",
|
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.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
subject: xdocs-prompts
|
|
3
|
+
description: Runtime prompt templates used by xdocs prompt commands and embedded into native binaries.
|
|
4
|
+
parent: xdocs-package
|
|
5
|
+
children: []
|
|
6
|
+
files: {}
|
|
7
|
+
documents:
|
|
8
|
+
agents.md: Prompt for updating AGENTS.md with xdocs instructions.
|
|
9
|
+
generate.md: Prompt for generating comprehensive documentation from xdocs metadata.
|
|
10
|
+
update.md: Prompt for updating existing xdocs descriptors after code or document changes.
|
|
11
|
+
write.md: Prompt for writing a named xdocs descriptor for a module.
|
|
12
|
+
tags:
|
|
13
|
+
- prompts
|
|
14
|
+
- ai
|
|
15
|
+
- documentation
|
|
16
|
+
keywords:
|
|
17
|
+
- prompts
|
|
18
|
+
- AI instructions
|
|
19
|
+
- documentation generation
|
|
20
|
+
flags: []
|
|
21
|
+
status: stable
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
The `prompts/` directory contains Markdown prompt templates loaded by
|
|
25
|
+
`source/prompts.ts` at runtime and embedded by `source/embedded-resources.ts` for
|
|
26
|
+
native binaries. They are plain companion documents, so this descriptor lists
|
|
27
|
+
each prompt under `documents`.
|
package/prompts/update.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: update
|
|
3
|
-
description: Update existing xdocs
|
|
3
|
+
description: Update existing xdocs descriptors after code or document changes.
|
|
4
|
+
keywords:
|
|
5
|
+
- update descriptor
|
|
6
|
+
- synchronize metadata
|
|
7
|
+
- documentation maintenance
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# xdocs: Update Documentation
|
|
@@ -10,22 +14,30 @@ You are an AI assistant tasked with updating existing xdocs documentation after
|
|
|
10
14
|
## Instructions
|
|
11
15
|
|
|
12
16
|
1. Identify which files have changed in the recent modifications.
|
|
13
|
-
2. Find the xdocs files that document the directories
|
|
14
|
-
|
|
17
|
+
2. Find the named `*.xdocs.md` descriptor files that document the directories
|
|
18
|
+
containing those changes. There must be exactly one descriptor per directory,
|
|
19
|
+
and it must not be named only `.xdocs.md`.
|
|
20
|
+
3. For each affected xdocs descriptor:
|
|
15
21
|
a. Re-read the files listed in the metadata to check if descriptions are still accurate.
|
|
16
22
|
b. Check if new files were added that need to be listed.
|
|
17
23
|
c. Check if files were removed that should be unlisted.
|
|
18
|
-
d.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
d. Check if sibling plain `*.md` documents were added or removed, and keep
|
|
25
|
+
the `documents` metadata map exact.
|
|
26
|
+
e. Update the description if the module's purpose has changed.
|
|
27
|
+
f. Update `keywords` if the module's searchable concepts changed.
|
|
28
|
+
g. Update children if subdirectories were added or removed.
|
|
29
|
+
h. Update the body content if significant changes occurred.
|
|
30
|
+
4. Preserve the existing structure and style of the xdocs descriptor.
|
|
22
31
|
5. Do not remove information that is still accurate.
|
|
23
32
|
|
|
24
33
|
## Checklist
|
|
25
34
|
|
|
26
35
|
- [ ] All new files are listed in the files metadata
|
|
27
36
|
- [ ] Removed files are no longer listed
|
|
37
|
+
- [ ] All sibling plain Markdown documents are listed in the documents metadata
|
|
38
|
+
- [ ] Removed Markdown documents are no longer listed
|
|
28
39
|
- [ ] File descriptions are accurate
|
|
29
40
|
- [ ] Module description reflects current state
|
|
41
|
+
- [ ] Keywords reflect current searchable concepts
|
|
30
42
|
- [ ] Children list matches actual subdirectories
|
|
31
43
|
- [ ] Parent reference is still correct
|
package/prompts/write.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: write
|
|
3
|
-
description: Scan a directory and write a new xdocs
|
|
3
|
+
description: Scan a directory and write a new named xdocs descriptor for it.
|
|
4
|
+
keywords:
|
|
5
|
+
- write descriptor
|
|
6
|
+
- xdocs metadata
|
|
7
|
+
- module documentation
|
|
4
8
|
---
|
|
5
9
|
|
|
6
10
|
# xdocs: Write Documentation
|
|
@@ -12,19 +16,25 @@ You are an AI assistant tasked with writing xdocs documentation for a directory/
|
|
|
12
16
|
1. Scan the target directory and all its subdirectories.
|
|
13
17
|
2. Read every source file to understand what it does.
|
|
14
18
|
3. Identify the purpose of this module/directory.
|
|
15
|
-
4. Create
|
|
19
|
+
4. Create a named xdocs descriptor with YAML frontmatter containing:
|
|
16
20
|
- subject: A short identifier for this module
|
|
17
21
|
- description: A concise description of what this module does
|
|
18
22
|
- parent: The parent module's subject (or null if this is a root module)
|
|
19
23
|
- children: List of child module subjects
|
|
20
24
|
- files: Map of filename to short description for each file
|
|
25
|
+
- documents: Map of same-directory plain Markdown filename to short description
|
|
21
26
|
- tags: Relevant tags (empty array if none)
|
|
27
|
+
- keywords: Search terms and concepts that should help agents match requests
|
|
22
28
|
- flags: Relevant flags (empty array if none)
|
|
23
29
|
5. Write a Markdown body below the frontmatter with:
|
|
24
30
|
- An overview section explaining the module in more detail
|
|
25
31
|
- Usage examples if relevant
|
|
26
32
|
- Any important notes or caveats
|
|
27
|
-
6. Name the file as `<module-name>.xdocs.md` in the target directory.
|
|
33
|
+
6. Name the file as `<module-name>.xdocs.md` in the target directory. Never name
|
|
34
|
+
a file only `.xdocs.md`; `.xdocs.md` is the extension, not the full filename.
|
|
35
|
+
7. Use only `.xdocs.md` for xdocs descriptors. Do not create `.docs.md` files.
|
|
36
|
+
8. If the directory contains sibling plain `*.md` files, list each one under
|
|
37
|
+
`documents` in this descriptor.
|
|
28
38
|
|
|
29
39
|
## Frontmatter Template
|
|
30
40
|
|
|
@@ -37,9 +47,12 @@ children:
|
|
|
37
47
|
- child-a
|
|
38
48
|
- child-b
|
|
39
49
|
files:
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
file-a.ts: What file-a does.
|
|
51
|
+
file-b.ts: What file-b does.
|
|
52
|
+
documents:
|
|
53
|
+
implementation-notes.md: What this companion document explains.
|
|
42
54
|
tags: []
|
|
55
|
+
keywords: []
|
|
43
56
|
flags: []
|
|
44
57
|
---
|
|
45
58
|
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Package-manager install helper for xdocs.
|
|
6
|
+
*
|
|
7
|
+
* This script downloads the platform-native xdocs binary into `vendor/xdocs` or
|
|
8
|
+
* `vendor/xdocs.exe`. Package-manager installs use the small Bun launcher in
|
|
9
|
+
* `scripts/xdocs-bin.ts`; direct installers remain the no-Bun runtime path.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type PackageJson = {
|
|
13
|
+
version?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const packageJson = await Bun.file(new URL('../package.json', import.meta.url)).json() as PackageJson
|
|
17
|
+
const sourceEntrypoint = Bun.file(new URL('../source/guiho-xdocs-bin.ts', import.meta.url))
|
|
18
|
+
|
|
19
|
+
if (await sourceEntrypoint.exists()) {
|
|
20
|
+
console.log('source checkout detected; skipping native binary download')
|
|
21
|
+
process.exit(0)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const version = process.env['XDOCS_VERSION'] ?? packageJson.version ?? 'latest'
|
|
25
|
+
const repo = process.env['XDOCS_REPO'] ?? 'CGuiho/xdocs'
|
|
26
|
+
const asset = detectAsset()
|
|
27
|
+
const bundledAsset = Bun.file(new URL(`../bin/${asset}`, import.meta.url))
|
|
28
|
+
const destination = new URL(`../vendor/xdocs${process.platform === 'win32' ? '.exe' : ''}`, import.meta.url)
|
|
29
|
+
|
|
30
|
+
if (await bundledAsset.exists()) {
|
|
31
|
+
await Bun.write(destination, bundledAsset)
|
|
32
|
+
await makeExecutable(destination)
|
|
33
|
+
console.log(`installed bundled xdocs native binary: ${asset}`)
|
|
34
|
+
process.exit(0)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const tag = version === 'latest' ? 'latest' : `@guiho/xdocs@${version}`
|
|
38
|
+
const url = tag === 'latest'
|
|
39
|
+
? `https://github.com/${repo}/releases/latest/download/${asset}`
|
|
40
|
+
: `https://github.com/${repo}/releases/download/${encodeURIComponent(tag)}/${asset}`
|
|
41
|
+
|
|
42
|
+
const response = await fetch(url)
|
|
43
|
+
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
console.error(`error: failed to download ${url}`)
|
|
46
|
+
console.error(`status: ${response.status} ${response.statusText}`)
|
|
47
|
+
process.exit(1)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await Bun.write(destination, response)
|
|
51
|
+
await makeExecutable(destination)
|
|
52
|
+
console.log(`installed xdocs native binary: ${asset}`)
|
|
53
|
+
|
|
54
|
+
async function makeExecutable(path: URL) {
|
|
55
|
+
if (process.platform === 'win32') return
|
|
56
|
+
|
|
57
|
+
const result = Bun.spawn(['chmod', '755', Bun.fileURLToPath(path)], {
|
|
58
|
+
stdout: 'ignore',
|
|
59
|
+
stderr: 'inherit',
|
|
60
|
+
})
|
|
61
|
+
const exitCode = await result.exited
|
|
62
|
+
|
|
63
|
+
if (exitCode !== 0) {
|
|
64
|
+
console.error('error: failed to make xdocs native binary executable')
|
|
65
|
+
process.exit(exitCode)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function detectAsset() {
|
|
70
|
+
const os = detectOs()
|
|
71
|
+
const arch = detectArch()
|
|
72
|
+
return `xdocs-${os}-${arch}${os === 'windows' ? '.exe' : ''}`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function detectOs() {
|
|
76
|
+
if (process.platform === 'linux') return 'linux'
|
|
77
|
+
if (process.platform === 'darwin') return 'macos'
|
|
78
|
+
if (process.platform === 'win32') return 'windows'
|
|
79
|
+
console.error(`error: unsupported OS: ${process.platform}`)
|
|
80
|
+
process.exit(1)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function detectArch() {
|
|
84
|
+
if (process.arch === 'x64') return 'x64'
|
|
85
|
+
if (process.arch === 'arm64') return 'arm64'
|
|
86
|
+
console.error(`error: unsupported architecture: ${process.arch}`)
|
|
87
|
+
process.exit(1)
|
|
88
|
+
}
|
package/scripts/scripts.xdocs.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
subject: xdocs-scripts
|
|
3
|
-
description: Package-manager installation scripts for
|
|
3
|
+
description: Package-manager launcher and installation scripts for executing the native xdocs binary.
|
|
4
4
|
parent: xdocs-package
|
|
5
5
|
children: []
|
|
6
6
|
files:
|
|
7
|
-
|
|
7
|
+
xdocs-bin.ts: Shipped Bun launcher used as the package bin; installs the native binary on first run when needed and delegates to it.
|
|
8
|
+
install-package.ts: Package-manager install helper that downloads or copies the matching GitHub Release native binary into vendor/xdocs or vendor/xdocs.exe.
|
|
9
|
+
documents: {}
|
|
8
10
|
tags:
|
|
9
11
|
- install
|
|
10
12
|
- native-binary
|
|
11
13
|
- package-manager
|
|
14
|
+
keywords:
|
|
15
|
+
- package launcher
|
|
16
|
+
- native binary
|
|
17
|
+
- vendor install
|
|
12
18
|
flags: []
|
|
13
19
|
status: stable
|
|
14
20
|
---
|
|
15
21
|
|
|
16
|
-
The `scripts/` directory contains package-manager
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
The `scripts/` directory contains the package-manager launcher and install
|
|
23
|
+
helper. Package-manager and `bunx` execution start in `xdocs-bin.ts`; if the
|
|
24
|
+
native binary is missing, it runs `install-package.ts` and then delegates to the
|
|
25
|
+
downloaded binary in `vendor/`. Direct installers remain the no-Bun runtime path.
|