@guiho/xdocs 0.1.3 → 0.2.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 +25 -0
- package/DOCS.md +522 -0
- package/README.md +36 -12
- package/jsr.json +3 -1
- package/library/agents.d.ts +76 -0
- package/library/agents.d.ts.map +1 -0
- package/library/agents.js +202 -0
- package/library/cli.d.ts.map +1 -1
- package/library/cli.js +11 -1
- package/library/commands/agents.d.ts +7 -0
- package/library/commands/agents.d.ts.map +1 -0
- package/library/commands/agents.js +64 -0
- package/library/commands/init.d.ts +1 -1
- package/library/commands/init.d.ts.map +1 -1
- package/library/commands/init.js +46 -38
- package/library/commands/scan.d.ts.map +1 -1
- package/library/commands/scan.js +2 -1
- package/library/config.d.ts +5 -1
- package/library/config.d.ts.map +1 -1
- package/library/config.js +37 -0
- package/library/flags.d.ts.map +1 -1
- package/library/flags.js +1 -0
- package/library/guiho-xdocs.d.ts +3 -2
- package/library/guiho-xdocs.d.ts.map +1 -1
- package/library/guiho-xdocs.js +3 -1
- package/library/help.d.ts.map +1 -1
- package/library/help.js +38 -3
- package/library/prompts.d.ts +5 -3
- package/library/prompts.d.ts.map +1 -1
- package/library/prompts.js +20 -13
- package/library/types.d.ts +41 -1
- package/library/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/skills/guiho-as-xdocs/SKILL.md +258 -0
package/library/guiho-xdocs.d.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
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 { XDocsAiMode, XDocsCliOptions, XDocsCommand, XDocsConfig, XDocsFile, XDocsFormat, XDocsMetadata, XDocsParsedArgs, XDocsPrompt, XDocsPromptName, XDocsRawConfig, XDocsScanResult, XDocsTreeNode, XDocsTreeValidation, } from './types.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';
|
|
6
6
|
export { parseArgs, stringFlag, booleanFlag, listFlag } from './flags.js';
|
|
7
|
-
export { createDefaultConfigContent, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
7
|
+
export { createDefaultConfigContent, DEFAULT_AGENT_SETTINGS, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeAgentSettings, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
8
8
|
export { 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';
|
|
12
12
|
export { getPrompt, getPromptNames, prompts } from './prompts.js';
|
|
13
|
+
export { detectAgentTools, ensureAgentsInstructions, findAgentsFile, installSkill, installSkills, isSkillInstalled, parseAgentTools, resolveAgentSettings, resolveInstallTools, resolveSkillPath, runAgentAutomation, standardAgentTool, xdocsAgentsSection, xdocsAgentTools, xdocsSkillContent, xdocsSkillName, } from './agents.js';
|
|
13
14
|
export { runCli, runCliWithErrorHandling } from './cli.js';
|
|
14
15
|
//# sourceMappingURL=guiho-xdocs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guiho-xdocs.d.ts","sourceRoot":"","sources":["../source/guiho-xdocs.ts"],"names":[],"mappings":"AAAA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|
6
6
|
// Flags
|
|
7
7
|
export { parseArgs, stringFlag, booleanFlag, listFlag } from './flags.js';
|
|
8
8
|
// Config
|
|
9
|
-
export { createDefaultConfigContent, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
9
|
+
export { createDefaultConfigContent, DEFAULT_AGENT_SETTINGS, defaultConfig, discoverConfig, loadConfig, loadConfigOrDefaults, normalizeAgentSettings, normalizeConfig, resolvePath, writeDefaultConfig, } from './config.js';
|
|
10
10
|
// Discovery
|
|
11
11
|
export { isXDocsFile, listDirectoryFiles, scanDirectory, scanProject } from './discovery.js';
|
|
12
12
|
// Metadata
|
|
@@ -17,5 +17,7 @@ export { buildTree, renderTree, renderTreeMarkdown, validateTree } from './tree.
|
|
|
17
17
|
export { readPackageVersion, showCommandHelp, showHelp, showVersion } from './help.js';
|
|
18
18
|
// Prompts
|
|
19
19
|
export { getPrompt, getPromptNames, prompts } from './prompts.js';
|
|
20
|
+
// Agents
|
|
21
|
+
export { detectAgentTools, ensureAgentsInstructions, findAgentsFile, installSkill, installSkills, isSkillInstalled, parseAgentTools, resolveAgentSettings, resolveInstallTools, resolveSkillPath, runAgentAutomation, standardAgentTool, xdocsAgentsSection, xdocsAgentTools, xdocsSkillContent, xdocsSkillName, } from './agents.js';
|
|
20
22
|
// CLI
|
|
21
23
|
export { runCli, runCliWithErrorHandling } from './cli.js';
|
package/library/help.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../source/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,kDAAkD;AAClD,eAAO,MAAM,kBAAkB,QAAO,MAQrC,CAAA;AAED,qCAAqC;AACrC,eAAO,MAAM,WAAW,QAAO,MAAyC,CAAA;AAExE,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,QAAO,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../source/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,kDAAkD;AAClD,eAAO,MAAM,kBAAkB,QAAO,MAQrC,CAAA;AAED,qCAAqC;AACrC,eAAO,MAAM,WAAW,QAAO,MAAyC,CAAA;AAExE,+BAA+B;AAC/B,eAAO,MAAM,QAAQ,QAAO,MAgCpB,CAAA;AAER,wCAAwC;AACxC,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAIjD,CAAA"}
|
package/library/help.js
CHANGED
|
@@ -29,6 +29,7 @@ Commands:
|
|
|
29
29
|
merge [path] Merge xdocs files from a directory into one file
|
|
30
30
|
tree Display the project hierarchy tree
|
|
31
31
|
list [path] List files with descriptions
|
|
32
|
+
agents Install the guiho-as-xdocs skill and AGENTS.md instructions
|
|
32
33
|
|
|
33
34
|
Global Flags:
|
|
34
35
|
-h, --help Show help for a command
|
|
@@ -45,6 +46,8 @@ Examples:
|
|
|
45
46
|
xdocs merge ./src/domain
|
|
46
47
|
xdocs tree
|
|
47
48
|
xdocs list ./src/auth
|
|
49
|
+
xdocs agents install local
|
|
50
|
+
xdocs agents instructions
|
|
48
51
|
`.trim();
|
|
49
52
|
/** Show help for a specific command. */
|
|
50
53
|
export const showCommandHelp = (command) => {
|
|
@@ -57,15 +60,21 @@ const commandHelpMap = {
|
|
|
57
60
|
init: `
|
|
58
61
|
xdocs init - Initialize xdocs in a project
|
|
59
62
|
|
|
60
|
-
Usage: xdocs init
|
|
63
|
+
Usage: xdocs init [--tool <agents|claude|all>] [--global]
|
|
61
64
|
|
|
62
65
|
Creates:
|
|
63
66
|
- XDOCS.md Root documentation file
|
|
64
67
|
- xdocs.config.toml Configuration with defaults
|
|
65
|
-
- Updates AGENTS.md Adds xdocs
|
|
66
|
-
- Installs
|
|
68
|
+
- Updates AGENTS.md Adds the xdocs section pointing AI at the skill
|
|
69
|
+
- Installs the skill guiho-as-xdocs into .agents/skills (standard, local)
|
|
70
|
+
|
|
71
|
+
By default the skill is installed for the standard target (AGENTS.md +
|
|
72
|
+
.agents/skills). The non-standard claude target (.claude/skills) is added only
|
|
73
|
+
when a .claude directory or CLAUDE.md is detected, or when requested via --tool.
|
|
67
74
|
|
|
68
75
|
Flags:
|
|
76
|
+
--tool <tool> agents (default/standard), claude, or all
|
|
77
|
+
--global Install the skill in the user home skills directory
|
|
69
78
|
--cwd <path> Target directory (default: current directory)
|
|
70
79
|
--verbose Show detailed output
|
|
71
80
|
`.trim(),
|
|
@@ -161,5 +170,31 @@ Flags:
|
|
|
161
170
|
--cwd <path> Target directory (default: current directory)
|
|
162
171
|
--config <path> Path to xdocs.config.toml
|
|
163
172
|
--verbose Show detailed output
|
|
173
|
+
`.trim(),
|
|
174
|
+
agents: `
|
|
175
|
+
xdocs agents - Install the guiho-as-xdocs skill and AGENTS.md instructions
|
|
176
|
+
|
|
177
|
+
Usage:
|
|
178
|
+
xdocs agents install <local|global> [--tool <tool>]
|
|
179
|
+
xdocs agents instructions
|
|
180
|
+
|
|
181
|
+
Subcommands:
|
|
182
|
+
install local Install the skill under the current project
|
|
183
|
+
install global Install the skill under the user home directory
|
|
184
|
+
instructions Insert or refresh the xdocs section in AGENTS.md
|
|
185
|
+
|
|
186
|
+
Skill locations:
|
|
187
|
+
agents (standard) <root>/.agents/skills/guiho-as-xdocs/SKILL.md
|
|
188
|
+
claude (non-standard) <root>/.claude/skills/guiho-as-xdocs/SKILL.md
|
|
189
|
+
|
|
190
|
+
<root> is the project for local scope, or the user home directory for global.
|
|
191
|
+
Without --tool, the standard agents target is installed, plus claude when a
|
|
192
|
+
.claude directory or CLAUDE.md is detected. Codex, Jules, and other AGENTS.md
|
|
193
|
+
tools read the standard target and the AGENTS.md instructions.
|
|
194
|
+
|
|
195
|
+
Flags:
|
|
196
|
+
--tool <tool> agents (default/standard), claude, or all
|
|
197
|
+
--format <format> Output format: text, json (default: text)
|
|
198
|
+
--cwd <path> Target directory (default: current directory)
|
|
164
199
|
`.trim(),
|
|
165
200
|
};
|
package/library/prompts.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*
|
|
4
|
-
* Prompt loader.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Prompt loader. Prompt `.md` files are read from disk at runtime (relative to
|
|
5
|
+
* this module via import.meta.url) so the compiled library works under both
|
|
6
|
+
* Node and Bun. Each `.md` file ships with the package in `prompts/`. Adding a
|
|
7
|
+
* new prompt requires creating the `.md` file and adding its name to
|
|
8
|
+
* PROMPT_NAMES.
|
|
7
9
|
*/
|
|
8
10
|
import type { XDocsPrompt } from './types.js';
|
|
9
11
|
/** All available prompts, keyed by name. */
|
package/library/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../source/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../source/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAmC7C,4CAA4C;AAC5C,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAWjD,CAAA;AAEJ,gDAAgD;AAChD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,WAAW,GAAG,SACpC,CAAA;AAEnB,4BAA4B;AAC5B,eAAO,MAAM,cAAc,QAAO,MAAM,EACnB,CAAA"}
|
package/library/prompts.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
3
|
*
|
|
4
|
-
* Prompt loader.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Prompt loader. Prompt `.md` files are read from disk at runtime (relative to
|
|
5
|
+
* this module via import.meta.url) so the compiled library works under both
|
|
6
|
+
* Node and Bun. Each `.md` file ships with the package in `prompts/`. Adding a
|
|
7
|
+
* new prompt requires creating the `.md` file and adding its name to
|
|
8
|
+
* PROMPT_NAMES.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
import writeRaw from '../prompts/write.md' with { type: 'text' };
|
|
10
|
-
// @ts-expect-error -- Bun text import, no TS declaration needed
|
|
11
|
-
import updateRaw from '../prompts/update.md' with { type: 'text' };
|
|
12
|
-
// @ts-expect-error -- Bun text import, no TS declaration needed
|
|
13
|
-
import agentsRaw from '../prompts/agents.md' with { type: 'text' };
|
|
14
|
-
// @ts-expect-error -- Bun text import, no TS declaration needed
|
|
15
|
-
import generateRaw from '../prompts/generate.md' with { type: 'text' };
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
16
11
|
import { extractFrontmatter } from './metadata.js';
|
|
17
|
-
const
|
|
12
|
+
const PROMPT_NAMES = ['write', 'update', 'agents', 'generate'];
|
|
13
|
+
/** Read a prompt file's raw contents, or undefined when it cannot be read. */
|
|
14
|
+
const readPromptFile = (name) => {
|
|
15
|
+
try {
|
|
16
|
+
return readFileSync(new URL(`../prompts/${name}.md`, import.meta.url), 'utf8');
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
18
22
|
/** Parse a raw prompt file into an XDocsPrompt. */
|
|
19
23
|
const parsePrompt = (raw) => {
|
|
20
24
|
const { frontmatter, body } = extractFrontmatter(raw);
|
|
@@ -37,7 +41,10 @@ const parsePrompt = (raw) => {
|
|
|
37
41
|
/** All available prompts, keyed by name. */
|
|
38
42
|
export const prompts = (() => {
|
|
39
43
|
const map = new Map();
|
|
40
|
-
for (const
|
|
44
|
+
for (const name of PROMPT_NAMES) {
|
|
45
|
+
const raw = readPromptFile(name);
|
|
46
|
+
if (!raw)
|
|
47
|
+
continue;
|
|
41
48
|
const prompt = parsePrompt(raw);
|
|
42
49
|
map.set(prompt.name, prompt);
|
|
43
50
|
}
|
package/library/types.d.ts
CHANGED
|
@@ -6,7 +6,15 @@ export type XDocsFormat = 'text' | 'json' | 'markdown';
|
|
|
6
6
|
/** AI behavior mode for documentation updates. */
|
|
7
7
|
export type XDocsAiMode = 'prompt' | 'auto';
|
|
8
8
|
/** Command names recognized by the CLI. */
|
|
9
|
-
export type XDocsCommand = 'init' | 'scan' | 'generate' | 'prompt' | 'merge' | 'tree' | 'list';
|
|
9
|
+
export type XDocsCommand = 'init' | 'scan' | 'generate' | 'prompt' | 'merge' | 'tree' | 'list' | 'agents';
|
|
10
|
+
/** AI tools the guiho-as-xdocs skill can be installed for.
|
|
11
|
+
*
|
|
12
|
+
* `agents` is the standard target (AGENTS.md + .agents/skills) and the default.
|
|
13
|
+
* `claude` is a non-standard target (.claude/skills) used only when explicitly
|
|
14
|
+
* requested or auto-detected. */
|
|
15
|
+
export type XDocsAgentTool = 'agents' | 'claude';
|
|
16
|
+
/** Scope of an agent-skill installation. */
|
|
17
|
+
export type XDocsSkillScope = 'local' | 'global';
|
|
10
18
|
/** Raw configuration as parsed from xdocs.config.toml. */
|
|
11
19
|
export type XDocsRawConfig = Partial<{
|
|
12
20
|
schema: number;
|
|
@@ -22,6 +30,11 @@ export type XDocsRawConfig = Partial<{
|
|
|
22
30
|
project: Partial<{
|
|
23
31
|
name: string;
|
|
24
32
|
}>;
|
|
33
|
+
agents: Partial<{
|
|
34
|
+
auto_agents_md: boolean;
|
|
35
|
+
auto_skill_install: boolean;
|
|
36
|
+
skill_tool: string;
|
|
37
|
+
}>;
|
|
25
38
|
}>;
|
|
26
39
|
/** Normalized, validated configuration. */
|
|
27
40
|
export type XDocsConfig = {
|
|
@@ -40,6 +53,13 @@ export type XDocsConfig = {
|
|
|
40
53
|
project: {
|
|
41
54
|
name: string;
|
|
42
55
|
};
|
|
56
|
+
agents: XDocsAgentSettings;
|
|
57
|
+
};
|
|
58
|
+
/** Normalized agent automation settings. */
|
|
59
|
+
export type XDocsAgentSettings = {
|
|
60
|
+
autoAgentsMd: boolean;
|
|
61
|
+
autoSkillInstall: boolean;
|
|
62
|
+
skillTool: XDocsAgentTool;
|
|
43
63
|
};
|
|
44
64
|
/** YAML frontmatter metadata from an xdocs file. */
|
|
45
65
|
export type XDocsMetadata = {
|
|
@@ -105,4 +125,24 @@ export type XDocsPrompt = {
|
|
|
105
125
|
description: string;
|
|
106
126
|
body: string;
|
|
107
127
|
};
|
|
128
|
+
/** Result of installing the guiho-as-xdocs skill for one tool/scope. */
|
|
129
|
+
export type XDocsSkillInstallResult = {
|
|
130
|
+
tool: XDocsAgentTool;
|
|
131
|
+
scope: XDocsSkillScope;
|
|
132
|
+
path: string;
|
|
133
|
+
installed: boolean;
|
|
134
|
+
updated: boolean;
|
|
135
|
+
};
|
|
136
|
+
/** Result of ensuring the xdocs section exists in AGENTS.md. */
|
|
137
|
+
export type XDocsAgentsInstructionsResult = {
|
|
138
|
+
path: string;
|
|
139
|
+
exists: boolean;
|
|
140
|
+
changed: boolean;
|
|
141
|
+
};
|
|
142
|
+
/** Result of the config-gated agent automation that runs on normal commands. */
|
|
143
|
+
export type XDocsAgentAutomationResult = {
|
|
144
|
+
settings: XDocsAgentSettings;
|
|
145
|
+
agentsMd?: XDocsAgentsInstructionsResult;
|
|
146
|
+
globalSkill?: XDocsSkillInstallResult;
|
|
147
|
+
};
|
|
108
148
|
//# sourceMappingURL=types.d.ts.map
|
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;AAC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CAAA;AAED,wEAAwE;AACxE,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;CACjB,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.2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./library/guiho-xdocs.js",
|
|
7
7
|
"types": "./library/guiho-xdocs.d.ts",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"README.md",
|
|
19
19
|
"library/",
|
|
20
20
|
"prompts/",
|
|
21
|
+
"skills/",
|
|
21
22
|
"docs/",
|
|
22
23
|
"jsr.json",
|
|
23
24
|
"CHANGELOG.md",
|
|
24
25
|
"LICENSE.md",
|
|
25
|
-
"
|
|
26
|
+
"DOCS.md"
|
|
26
27
|
],
|
|
27
28
|
"keywords": [
|
|
28
29
|
"ai",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"yaml": "^2.9.0"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
|
-
"@guiho/mirror": "^3.
|
|
75
|
+
"@guiho/mirror": "^3.1.2",
|
|
75
76
|
"@types/bun": "1.3.14",
|
|
76
77
|
"typescript": "6.0.3"
|
|
77
78
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: guiho-as-xdocs
|
|
3
|
+
description: Use this skill whenever the user works with xdocs (`@guiho/xdocs`) structured documentation, AND proactively whenever you create a new module or subdirectory or add/change/remove files in a directory of an xdocs project, so you create or update that directory's `.xdocs.md` as part of the change. This includes creating, updating, or regenerating `.docs.md` / `.xdocs.md` files, the root `XDOCS.md`, the project tree, scanning documentation coverage, merging docs, or maintaining xdocs metadata and AGENTS.md guidance, even when the user only says "document this module", "update the docs", or "what does this folder do" without naming xdocs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GUIHO XDocs
|
|
7
|
+
|
|
8
|
+
GUIHO XDocs is a deterministic CLI and TypeScript library for **structured documentation of codebases**. It lets an AI agent understand a project without reading every source file: each directory carries a small Markdown file with YAML frontmatter that describes its subject, purpose, files, and place in a parent-child hierarchy.
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
source tree -> xdocs files (.docs.md / .xdocs.md) -> tree + metadata -> AI-readable map
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Use xdocs for documentation work instead of ad hoc README sprawl or re-reading the whole codebase. The value of xdocs is that the structure (subjects, descriptions, files, parent/child links) is machine-readable and stays close to the code it describes.
|
|
15
|
+
|
|
16
|
+
## Command Selection
|
|
17
|
+
|
|
18
|
+
Choose the xdocs command in this order:
|
|
19
|
+
|
|
20
|
+
1. Use `bun @guiho/xdocs` when the package is installed locally and Bun is available.
|
|
21
|
+
2. Use `xdocs` when a global binary is available.
|
|
22
|
+
3. Use `bunx @guiho/xdocs` when running without installation.
|
|
23
|
+
|
|
24
|
+
When unsure, run a cheap availability check (`bun @guiho/xdocs --help`, `xdocs --help`, or `bunx @guiho/xdocs --help`) and then reuse the working command consistently. Run `xdocs --help` or `xdocs <command> --help` for command-specific details when needed.
|
|
25
|
+
|
|
26
|
+
xdocs is a Bun/TypeScript ESM tool. Bun is the recommended runtime. The CLI never bumps versions or mutates `package.json` — it only reads and writes documentation files. (Versioning is a separate concern handled by GUIHO Mirror.)
|
|
27
|
+
|
|
28
|
+
## Core Concepts
|
|
29
|
+
|
|
30
|
+
- **xdocs file**: a Markdown file with YAML frontmatter that documents one directory/module. Default extensions are `.docs.md` and `.xdocs.md`. Extensions are configurable in `xdocs.config.toml`.
|
|
31
|
+
- **Repository root index**: there is exactly one `XDOCS.md` per repository, at the repo root. It has **no frontmatter** — it is a plain index that lists the repository's packages and applications, and it is not itself a tree node.
|
|
32
|
+
- **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.
|
|
33
|
+
- **Tree**: a parent-child **containment** hierarchy (not a dependency graph), assembled from each `.xdocs.md` / `.docs.md` file's `subject` / `parent` / `children` fields. A module's `parent` is the `subject` of the module that contains it; a package/application root uses `parent: null`.
|
|
34
|
+
- **AI mode**: `xdocs.config.toml` `[ai].mode` is either `"prompt"` (announce the documentation updates, then write them) or `"auto"` (write immediately). It governs *how* you write docs, not *whether* — documenting a changed module is always required (see Automatic Documentation Maintenance).
|
|
35
|
+
|
|
36
|
+
### Metadata schema (YAML frontmatter)
|
|
37
|
+
|
|
38
|
+
Every `.xdocs.md` / `.docs.md` file carries frontmatter with these fields. The repository's single `XDOCS.md` is the exception: it has no frontmatter and is just an index.
|
|
39
|
+
|
|
40
|
+
| Field | Type | Meaning |
|
|
41
|
+
| ------------- | --------------------- | ------------------------------------------------------------ |
|
|
42
|
+
| `subject` | string | Unique identifier/name of this module in the tree. |
|
|
43
|
+
| `description` | string | One-line summary of what the module does. |
|
|
44
|
+
| `parent` | string \| null | `subject` of the containing module; `null` for a package/application root. |
|
|
45
|
+
| `children` | string[] | `subject`s of directly contained modules. |
|
|
46
|
+
| `files` | map<string,string> | Filename -> short description of each significant file. |
|
|
47
|
+
| `tags` | string[] | Free-form classification labels. |
|
|
48
|
+
| `flags` | string[] | Behavioral markers for tools/agents. |
|
|
49
|
+
| `status` | string (optional) | Lifecycle marker (e.g. `stable`, `draft`, `deprecated`). |
|
|
50
|
+
|
|
51
|
+
Keep `subject` values unique across the project, keep `parent`/`children` consistent in both directions, and keep `files` in sync with what is actually on disk.
|
|
52
|
+
|
|
53
|
+
## Automatic Documentation Maintenance (core responsibility)
|
|
54
|
+
|
|
55
|
+
Maintaining xdocs files is an **automatic, built-in responsibility — not a task the user has to request.** Treat it as part of the definition of done for every code change in an xdocs project. The user should never have to ask you to document a module; you do it as a reflex whenever you touch one.
|
|
56
|
+
|
|
57
|
+
**Trigger.** Whenever you, as the agent, do any of the following, you must create or update the affected directory's xdocs file in the *same unit of work*, before you consider the task finished:
|
|
58
|
+
|
|
59
|
+
- Create a new directory, module, or subpackage.
|
|
60
|
+
- Add, rename, move, or delete significant files in a directory.
|
|
61
|
+
- Change what a module does, what it exposes, or how it relates to its parent or children.
|
|
62
|
+
|
|
63
|
+
**Action.**
|
|
64
|
+
|
|
65
|
+
- If the directory has **no** xdocs file, create one (for example `<name>.xdocs.md`) in that directory.
|
|
66
|
+
- If it **already** has one, update it so it matches the new reality.
|
|
67
|
+
- Then fix the parent/child links and verify with `<xdocs> tree`.
|
|
68
|
+
|
|
69
|
+
**What every module's xdocs file must capture:**
|
|
70
|
+
|
|
71
|
+
- `subject` — the module's unique name in the tree.
|
|
72
|
+
- `description` — the module's **purpose**: what it is for and what it does.
|
|
73
|
+
- `files` — each significant file in the directory mapped to a short description of its responsibility, **including the key functions/exports it provides**.
|
|
74
|
+
- `parent` — the `subject` of the containing module (and add this module to that parent's `children`).
|
|
75
|
+
- `children` — the `subject`s of the modules contained inside this one.
|
|
76
|
+
|
|
77
|
+
**Do not wait to be asked.** After you finish creating or modifying a module or directory, create or update its xdocs file as part of the same change. A code change that adds or alters a module is **not complete** until its xdocs file and the affected parent/child links are updated.
|
|
78
|
+
|
|
79
|
+
**How `[ai].mode` applies.** The mode controls only *how* you write the docs, never *whether* you write them and never whether the user must ask first:
|
|
80
|
+
|
|
81
|
+
- `auto` — create/update the xdocs files immediately as part of the change, then report what changed.
|
|
82
|
+
- `prompt` — state exactly which xdocs files you are creating or updating, then write them (honoring any pending confirmation). Announcing is for transparency; it does not make documentation optional and the user never has to request it.
|
|
83
|
+
|
|
84
|
+
### Example: documenting a new module
|
|
85
|
+
|
|
86
|
+
Suppose you just created `src/auth/` with `login.ts` and `session.ts`. As part of that work, create `src/auth/auth.xdocs.md`:
|
|
87
|
+
|
|
88
|
+
```markdown
|
|
89
|
+
---
|
|
90
|
+
subject: auth
|
|
91
|
+
description: Authentication and session handling for the API.
|
|
92
|
+
parent: src
|
|
93
|
+
children: []
|
|
94
|
+
files:
|
|
95
|
+
login.ts: Email/password login flow; exports `login()` and `verifyPassword()`.
|
|
96
|
+
session.ts: Session lifecycle; exports `createSession()` and `validateSession()`.
|
|
97
|
+
tags:
|
|
98
|
+
- security
|
|
99
|
+
flags: []
|
|
100
|
+
status: stable
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
Auth validates credentials and issues sessions. `login()` delegates password
|
|
104
|
+
checks to `verifyPassword()`; sessions are created and validated in `session.ts`.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Then add `auth` to the `children` list of the `src` module's xdocs file so the tree stays consistent.
|
|
108
|
+
|
|
109
|
+
If the directory you are documenting is the **root of a package or application** (not a sub-module), set `parent: null` instead, and list that package's root `.xdocs.md` in the repository's single `XDOCS.md` index rather than in a parent module's `children`.
|
|
110
|
+
|
|
111
|
+
## Onboarding Workflow (entering a project)
|
|
112
|
+
|
|
113
|
+
When you start working in a project that uses xdocs:
|
|
114
|
+
|
|
115
|
+
1. Read the root `XDOCS.md` to learn the project's top-level subject and structure.
|
|
116
|
+
2. Run `<xdocs> tree` to see the module hierarchy.
|
|
117
|
+
3. Run `<xdocs> scan` to see documentation coverage and which directories are missing xdocs files.
|
|
118
|
+
4. Read `xdocs.config.toml` and note `[ai].mode`, the supported `[extensions]`, and `[scan].exclude`.
|
|
119
|
+
5. When you navigate into a module, read that module's xdocs file (frontmatter first, body only if you need more) instead of reading every source file.
|
|
120
|
+
|
|
121
|
+
## Documentation Workflow (writing and updating)
|
|
122
|
+
|
|
123
|
+
Follow this whenever the automatic trigger above fires, or when the user asks to document a directory:
|
|
124
|
+
|
|
125
|
+
1. Determine the target directory and whether it already has an xdocs file (`<xdocs> scan` or `<xdocs> list <path>`).
|
|
126
|
+
2. Read the directory's actual files so the documentation reflects reality. Never invent files, modules, or behavior that is not present.
|
|
127
|
+
3. Respect `[ai].mode` (it controls how you write, not whether you write):
|
|
128
|
+
- **prompt mode**: state exactly which xdocs files you are creating or updating, then write them (honor a pending confirmation, but never skip the documentation).
|
|
129
|
+
- **auto mode**: create or update the xdocs files immediately, then report what changed.
|
|
130
|
+
4. Write or update the xdocs file with correct frontmatter:
|
|
131
|
+
- Set `subject` (unique), `description` (the module's purpose), and `files` (each real file -> short purpose, including key functions/exports).
|
|
132
|
+
- Set `parent` to the containing module's `subject`, and add this `subject` to that parent's `children`.
|
|
133
|
+
- Use `tags`/`flags`/`status` where useful.
|
|
134
|
+
5. Keep the tree consistent: if you add a module, update its parent's `children`; if you remove one, update both sides.
|
|
135
|
+
6. Validate with `<xdocs> tree` (it reports duplicate subjects, orphans, and missing children) and fix any reported issues.
|
|
136
|
+
|
|
137
|
+
When generating from scratch, prefer `<xdocs> generate <path>` (one directory) or `<xdocs> generate` (whole project) to produce a starting draft, then refine the content by hand.
|
|
138
|
+
|
|
139
|
+
## Command-to-Task Mapping
|
|
140
|
+
|
|
141
|
+
- "Set up xdocs here" -> `<xdocs> init`
|
|
142
|
+
- "What is documented / what is missing" -> `<xdocs> scan`
|
|
143
|
+
- "Show me the structure" -> `<xdocs> tree`
|
|
144
|
+
- "What is in this folder" -> `<xdocs> list <path>`
|
|
145
|
+
- "Draft docs for this module / project" -> `<xdocs> generate [path]`
|
|
146
|
+
- "Give me one combined document" -> `<xdocs> merge [path]`
|
|
147
|
+
- "Give me the AI instructions for writing/updating docs" -> `<xdocs> prompt --name=<write|update|agents|generate>`
|
|
148
|
+
- "Install the xdocs skill / update AGENTS.md" -> `<xdocs> agents install <local|global>` / `<xdocs> agents instructions`
|
|
149
|
+
|
|
150
|
+
## Safety Rules
|
|
151
|
+
|
|
152
|
+
- Never leave a new or changed module undocumented. Creating or updating its xdocs file is part of finishing the work, not a separate request the user must make.
|
|
153
|
+
- Never fabricate files, modules, descriptions, or relationships. Documentation must match the repository.
|
|
154
|
+
- Never edit generated or build outputs (`library/`, `bundle/`, `bin/`, `*.tgz`). They are ignored and regenerated.
|
|
155
|
+
- In prompt mode, announce the xdocs changes you will make and honor a pending confirmation — but still treat documenting the change as required, never optional.
|
|
156
|
+
- Do not break tree integrity: every `child` must have a matching `parent`, and every `subject` must be unique.
|
|
157
|
+
- Do not silently change a module's `subject` — it is the identity used by `parent`/`children` links across the project.
|
|
158
|
+
- When `<xdocs> tree` or `<xdocs> scan` reports warnings, resolve them rather than ignoring them.
|
|
159
|
+
|
|
160
|
+
## Configuration Reference
|
|
161
|
+
|
|
162
|
+
xdocs searches for configuration via `--config <path>`, `./xdocs.config.toml`, or `./config/xdocs.config.toml`.
|
|
163
|
+
|
|
164
|
+
```toml
|
|
165
|
+
schema = 1
|
|
166
|
+
|
|
167
|
+
[extensions]
|
|
168
|
+
supported = [".docs.md", ".xdocs.md"]
|
|
169
|
+
|
|
170
|
+
[ai]
|
|
171
|
+
mode = "prompt" # "prompt" (announce and wait) or "auto" (update immediately)
|
|
172
|
+
|
|
173
|
+
[scan]
|
|
174
|
+
exclude = ["node_modules", ".git", "dist", "build", "library", "bin", "bundle"]
|
|
175
|
+
|
|
176
|
+
[project]
|
|
177
|
+
name = "my-project"
|
|
178
|
+
|
|
179
|
+
[agents]
|
|
180
|
+
auto_agents_md = true # keep the xdocs section in AGENTS.md up to date on normal commands
|
|
181
|
+
auto_skill_install = true # install the guiho-as-xdocs skill globally when missing
|
|
182
|
+
skill_tool = "agents" # default tool for auto-install: agents (standard) or claude
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Agent automation options default to true. Set `auto_agents_md = false` to stop xdocs from touching AGENTS.md, and `auto_skill_install = false` to stop xdocs from installing `guiho-as-xdocs` globally when it is missing.
|
|
186
|
+
|
|
187
|
+
## CLI Reference
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
xdocs init # create XDOCS.md + xdocs.config.toml, update AGENTS.md, install the skill
|
|
191
|
+
xdocs scan # report xdocs coverage across the project
|
|
192
|
+
xdocs tree # print the module hierarchy
|
|
193
|
+
xdocs list <path> # list files in a scope with descriptions
|
|
194
|
+
xdocs generate [path] # draft documentation for a directory or the whole project
|
|
195
|
+
xdocs merge [path] # merge a directory's xdocs files into one document
|
|
196
|
+
xdocs prompt --name=<name> # print a ready-made AI prompt (write|update|agents|generate)
|
|
197
|
+
xdocs agents install local # install guiho-as-xdocs into this project (.agents/skills/...)
|
|
198
|
+
xdocs agents install global # install guiho-as-xdocs into the user home skills directory
|
|
199
|
+
xdocs agents instructions # insert/refresh the xdocs section in AGENTS.md
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Global flags: `--help`, `--version`, `--cwd <path>`, `--config <path>`, `--format <text|json|markdown>`, `--verbose`. The `agents install` command also accepts `--tool <agents|claude|all>`.
|
|
203
|
+
|
|
204
|
+
## Agent Skill Installation
|
|
205
|
+
|
|
206
|
+
xdocs ships this `guiho-as-xdocs` skill. The **standard** target is `AGENTS.md`
|
|
207
|
+
plus `.agents/skills`, which OpenCode, Codex, Jules, and any AGENTS.md-aware tool
|
|
208
|
+
read. A **non-standard** Claude Code target exists and is used only when it is
|
|
209
|
+
explicitly requested (`--tool claude`) or detected (a `.claude` directory or
|
|
210
|
+
`CLAUDE.md` in the project).
|
|
211
|
+
|
|
212
|
+
| Target | Skill location (local) |
|
|
213
|
+
| ----------------------- | ------------------------------------------- |
|
|
214
|
+
| **agents** (standard) | `.agents/skills/guiho-as-xdocs/SKILL.md` |
|
|
215
|
+
| **claude** (non-standard) | `.claude/skills/guiho-as-xdocs/SKILL.md` |
|
|
216
|
+
|
|
217
|
+
`local` scope installs under the current project; `global` scope installs under
|
|
218
|
+
the user home directory (`~/.agents/skills/...`). The small section in `AGENTS.md`
|
|
219
|
+
written by `xdocs agents instructions` is the standard pointer that tells any
|
|
220
|
+
agent to load this skill.
|
|
221
|
+
|
|
222
|
+
Default to the standard target. Only install or write non-standard files
|
|
223
|
+
(`.claude`, `CLAUDE.md`, etc.) when the user asks for them or when those files
|
|
224
|
+
already exist in the project.
|
|
225
|
+
|
|
226
|
+
## TypeScript API
|
|
227
|
+
|
|
228
|
+
When the user wants automation code rather than CLI usage, use the typed API:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { loadConfigOrDefaults, scanProject, buildTree, renderTree } from '@guiho/xdocs'
|
|
232
|
+
|
|
233
|
+
const config = await loadConfigOrDefaults({ cwd: process.cwd(), format: 'text', verbose: false })
|
|
234
|
+
const scan = await scanProject(config)
|
|
235
|
+
const tree = buildTree(scan.xdocsFiles)
|
|
236
|
+
|
|
237
|
+
console.log(renderTree(tree))
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
For agent-skill and AGENTS.md automation:
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { installSkill, ensureAgentsInstructions } from '@guiho/xdocs'
|
|
244
|
+
|
|
245
|
+
await installSkill('agents', 'local', { cwd: process.cwd() })
|
|
246
|
+
await ensureAgentsInstructions(process.cwd(), true)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Response Style
|
|
250
|
+
|
|
251
|
+
When reporting an xdocs result, include:
|
|
252
|
+
|
|
253
|
+
- The command that ran and the target path.
|
|
254
|
+
- Which xdocs files were created or changed, if any.
|
|
255
|
+
- Tree/coverage status (subjects added, orphans or duplicates resolved).
|
|
256
|
+
- The configured AI mode, and — in prompt mode — exactly what you are waiting to write.
|
|
257
|
+
|
|
258
|
+
Keep the explanation short and operational. The user usually needs to know which docs changed, whether the tree is still consistent, and what (if anything) remains for them to confirm.
|