@guiho/xdocs 0.2.2 → 0.2.3
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 +5 -0
- package/DOCS.md +7 -1
- package/jsr.json +1 -1
- package/library/agents.d.ts +1 -1
- package/library/agents.d.ts.map +1 -1
- package/library/agents.js +15 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# GUIHO XDocs Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
- `xdocs agents instructions` and config-gated AGENTS.md automation now tolerate formatter-only blank lines and trailing whitespace inside the managed xdocs block, preserving the user's formatted block when the actual text is unchanged.
|
|
6
|
+
- Update the managed AGENTS.md xdocs block wording to match the current repository model: one root `XDOCS.md` index and package/application root `.xdocs.md` files.
|
|
7
|
+
|
|
3
8
|
## 0.2.2
|
|
4
9
|
|
|
5
10
|
- Fix: the published library crashed under Node (`ERR_UNKNOWN_FILE_EXTENSION` for `.md`) because the prompts and the `guiho-as-xdocs` skill were loaded with Bun-only text imports. They are now read from disk at runtime (`readFileSync` relative to `import.meta.url`), so the `xdocs` CLI and the library work under both Node and Bun.
|
package/DOCS.md
CHANGED
|
@@ -247,6 +247,12 @@ xdocs agents instructions # insert/refresh the AGENTS.md section
|
|
|
247
247
|
- `install global`: Writes the skill under the user home skills directory.
|
|
248
248
|
- `instructions`: Creates or refreshes the xdocs section in `AGENTS.md`.
|
|
249
249
|
|
|
250
|
+
When refreshing the `AGENTS.md` section, XDocs compares the existing section to
|
|
251
|
+
the canonical section while ignoring blank-only lines and trailing whitespace.
|
|
252
|
+
This means Markdown formatters that add blank lines around the section markers do
|
|
253
|
+
not cause repeated rewrites. Real text changes are still replaced with the
|
|
254
|
+
canonical section.
|
|
255
|
+
|
|
250
256
|
Flags: `--tool <agents|claude|all>`, `--format <text|json>`, `--cwd`.
|
|
251
257
|
|
|
252
258
|
When `--tool` is omitted, XDocs installs the standard target and adds the Claude target only when a `.claude/` directory or `CLAUDE.md` is detected in the project. Global skill installation uses the user home directory; tests and automation can override that home root with `XDOCS_AGENT_HOME`.
|
|
@@ -405,7 +411,7 @@ The API uses the same configuration discovery and validation as the CLI.
|
|
|
405
411
|
- `source/flags.ts`: argument/flag parsing utilities.
|
|
406
412
|
- `source/errors.ts`: `XDocsError` with stable exit codes and the `invariant` helper.
|
|
407
413
|
- `source/types.ts`: public and internal TypeScript types.
|
|
408
|
-
- `source/agents.ts`: agent skill installation (standard/claude, local/global), AGENTS.md section management, detection, and config-gated automation.
|
|
414
|
+
- `source/agents.ts`: agent skill installation (standard/claude, local/global), AGENTS.md section management, detection, and config-gated automation. Reads `skills/guiho-as-xdocs/SKILL.md` from disk at runtime relative to `import.meta.url`.
|
|
409
415
|
- `source/commands/*.ts`: one file per CLI command (`init`, `scan`, `generate`, `prompt`, `merge`, `tree`, `list`, `agents`).
|
|
410
416
|
- `prompts/*.md`: prompt templates embedded at build time.
|
|
411
417
|
- `skills/guiho-as-xdocs/SKILL.md`: bundled AI-agent skill installed by `xdocs agents` commands.
|
package/jsr.json
CHANGED
package/library/agents.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const detectAgentTools: (cwd: string) => XDocsAgentTool[];
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const resolveInstallTools: (cwd: string, toolFlag: string | undefined) => XDocsAgentTool[];
|
|
36
36
|
/** The small AGENTS.md section announcing xdocs and pointing to the skill. */
|
|
37
|
-
export declare const xdocsAgentsSection = "<!-- BEGIN XDOCS \u2014 DO NOT EDIT THIS SECTION -->\n## XDocs Structured Documentation\n\nThis project uses **xdocs** (`@guiho/xdocs`) for structured, machine-readable\ndocumentation. Each module carries a
|
|
37
|
+
export declare const xdocsAgentsSection = "<!-- BEGIN XDOCS \u2014 DO NOT EDIT THIS SECTION -->\n## XDocs Structured Documentation\n\nThis project uses **xdocs** (`@guiho/xdocs`) for structured, machine-readable\ndocumentation. The repository has one root `XDOCS.md` index (no frontmatter),\nand each package/application has a root `.xdocs.md` file. Each module carries a\n`.docs.md` / `.xdocs.md` file with YAML frontmatter (`subject`, `description`,\n`parent`, `children`, `files`).\n\n**Load the `guiho-as-xdocs` agent skill** for any documentation work:\ncreating, updating, regenerating, scanning, merging, or navigating xdocs files.\nThe skill holds the full workflow, metadata schema, and CLI reference.\n\nBefore changing documentation, read `xdocs.config.toml` and respect `[ai].mode`:\n\n- **prompt** \u2014 announce which xdocs files need updating and wait for confirmation.\n- **auto** \u2014 update the relevant xdocs files immediately.\n\nUse the xdocs CLI for operations: `xdocs scan`, `xdocs tree`, `xdocs generate`,\n`xdocs list`, `xdocs merge`.\n<!-- END XDOCS -->";
|
|
38
38
|
type SkillPathOptions = {
|
|
39
39
|
cwd?: string;
|
|
40
40
|
homeDirectory?: string;
|
package/library/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../source/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,6BAA6B,EAC7B,eAAe,EACf,uBAAuB,EACvB,eAAe,EAChB,MAAM,YAAY,CAAA;AAInB,+CAA+C;AAC/C,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAE9C;;iEAEiE;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAM5B,CAAA;AAEJ,6EAA6E;AAC7E,eAAO,MAAM,eAAe,EAAE,SAAS,cAAc,EAAyB,CAAA;AAE9E,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,EAAE,cAAyB,CAAA;AAEzD,2FAA2F;AAC3F,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,cAAc,EAKzE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,cAAc,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e,GAAG;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,EAAE,OAAO,eAAe,EAAE,UAAS,gBAAqB,KAAG,MAG/G,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,EAAE,OAAO,eAAe,EAAE,UAAS,gBAAqB,KAAG,OAC5D,CAAA;AAEpD,kEAAkE;AAClE,eAAO,MAAM,YAAY,GACvB,MAAM,cAAc,EACpB,OAAO,eAAe,EACtB,UAAS,mBAAwB,KAChC,OAAO,CAAC,uBAAuB,CAajC,CAAA;AAED,mDAAmD;AACnD,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,cAAc,EAAE,EAChC,OAAO,eAAe,EACtB,UAAS,mBAAwB,KAChC,OAAO,CAAC,uBAAuB,EAAE,CAInC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAU,KAAK,MAAM,EAAE,gBAAc,KAAG,OAAO,CAAC,6BAA6B,CAkBjH,CAAA;AA4BD,sDAAsD;AACtD,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAWrD,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,GAAU,SAAS,eAAe,KAAG,OAAO,CAAC,kBAAkB,CAI/F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,sBAAsB,EAC/B,SAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,KAC3C,OAAO,CAAC,0BAA0B,CAkBpC,CAAA"}
|
package/library/agents.js
CHANGED
|
@@ -78,9 +78,10 @@ export const xdocsAgentsSection = `${AGENTS_BEGIN_MARKER}
|
|
|
78
78
|
## XDocs Structured Documentation
|
|
79
79
|
|
|
80
80
|
This project uses **xdocs** (\`@guiho/xdocs\`) for structured, machine-readable
|
|
81
|
-
documentation.
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
documentation. The repository has one root \`XDOCS.md\` index (no frontmatter),
|
|
82
|
+
and each package/application has a root \`.xdocs.md\` file. Each module carries a
|
|
83
|
+
\`.docs.md\` / \`.xdocs.md\` file with YAML frontmatter (\`subject\`, \`description\`,
|
|
84
|
+
\`parent\`, \`children\`, \`files\`).
|
|
84
85
|
|
|
85
86
|
**Load the \`${xdocsSkillName}\` agent skill** for any documentation work:
|
|
86
87
|
creating, updating, regenerating, scanning, merging, or navigating xdocs files.
|
|
@@ -149,12 +150,22 @@ const upsertAgentsSection = (content) => {
|
|
|
149
150
|
const begin = content.indexOf(AGENTS_BEGIN_MARKER);
|
|
150
151
|
const end = content.indexOf(AGENTS_END_MARKER);
|
|
151
152
|
if (begin !== -1 && end !== -1 && end > begin) {
|
|
153
|
+
const blockEnd = end + AGENTS_END_MARKER.length;
|
|
154
|
+
const currentBlock = content.slice(begin, blockEnd);
|
|
155
|
+
if (normalizeAgentsSection(currentBlock) === normalizeAgentsSection(xdocsAgentsSection))
|
|
156
|
+
return content;
|
|
152
157
|
const before = content.slice(0, begin);
|
|
153
|
-
const after = content.slice(
|
|
158
|
+
const after = content.slice(blockEnd);
|
|
154
159
|
return `${before}${xdocsAgentsSection}${after}`;
|
|
155
160
|
}
|
|
156
161
|
return `${content.trimEnd()}\n\n${xdocsAgentsSection}\n`;
|
|
157
162
|
};
|
|
163
|
+
/** Ignore blank-only lines and trailing whitespace when comparing formatted sections. */
|
|
164
|
+
const normalizeAgentsSection = (content) => content
|
|
165
|
+
.split(/\r?\n/)
|
|
166
|
+
.map((line) => line.trimEnd())
|
|
167
|
+
.filter((line) => line.trim().length > 0)
|
|
168
|
+
.join('\n');
|
|
158
169
|
/** Walk up from cwd to find the nearest AGENTS.md. */
|
|
159
170
|
export const findAgentsFile = (cwd) => {
|
|
160
171
|
let current = resolve(cwd);
|
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.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./library/guiho-xdocs.js",
|
|
7
7
|
"types": "./library/guiho-xdocs.d.ts",
|