@guiho/xdocs 0.3.0-alpha.2 → 0.3.1
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 +11 -0
- package/DOCS.md +10 -9
- package/README.md +8 -4
- package/jsr.json +1 -1
- package/library/agents.d.ts +3 -4
- package/library/agents.d.ts.map +1 -1
- package/library/agents.js +5 -8
- package/library/cli.d.ts.map +1 -1
- package/library/cli.js +5 -4
- package/package.json +3 -3
- package/scripts/install-package.ts +88 -0
- package/scripts/scripts.xdocs.md +7 -5
- package/scripts/xdocs-bin.ts +33 -0
- package/skills/guiho-s-xdocs/SKILL.md +3 -3
- package/scripts/install-native.cjs +0 -101
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# GUIHO XDocs Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
- Fix bare `xdocs` invocations so they install or refresh the global `guiho-s-xdocs` skill before printing help, even without `xdocs.config.toml`, and remove legacy `guiho-as-xdocs` installs for that target.
|
|
6
|
+
- Change the package-manager `xdocs` bin to a shipped Bun launcher (`scripts/xdocs-bin.ts`) that installs the native binary on first run when needed, matching GUIHO Mirror's `bun x` behavior.
|
|
7
|
+
|
|
8
|
+
## 0.3.0
|
|
9
|
+
|
|
10
|
+
- Stabilize the 0.3.0 release line, including native binary distribution, direct installers, package-manager native binary installation, and Bun-native TOML/YAML parsing.
|
|
11
|
+
- Ship the renamed `guiho-s-xdocs` agent skill with versioned frontmatter, automatic refresh from the bundled package copy, and legacy `guiho-as-xdocs` cleanup.
|
|
12
|
+
- Refresh README guidance and regression coverage for the stable release.
|
|
13
|
+
|
|
3
14
|
## 0.3.0-alpha.2
|
|
4
15
|
|
|
5
16
|
- Rename the bundled xdocs agent skill from `guiho-as-xdocs` to `guiho-s-xdocs` and add a frontmatter `version` field.
|
package/DOCS.md
CHANGED
|
@@ -13,7 +13,7 @@ XDocs is a documentation tool, not a versioning tool. It never bumps versions or
|
|
|
13
13
|
- Package name: `@guiho/xdocs`
|
|
14
14
|
- Source/runtime during development: Bun and TypeScript (ESM)
|
|
15
15
|
- Primary release runtime: compiled native Bun binary assets
|
|
16
|
-
- Package-manager install path:
|
|
16
|
+
- Package-manager install path: the shipped Bun launcher runs `postinstall` or first-run native binary installation, then executes the native binary
|
|
17
17
|
- Package type: ESM
|
|
18
18
|
- Library entrypoint: `source/guiho-xdocs.ts`
|
|
19
19
|
- CLI entrypoint: `source/guiho-xdocs-bin.ts`
|
|
@@ -93,7 +93,7 @@ curl -fsSL https://raw.githubusercontent.com/CGuiho/xdocs/main/install.sh | sh
|
|
|
93
93
|
irm https://raw.githubusercontent.com/CGuiho/xdocs/main/install.ps1 | iex
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
Install XDocs as a development dependency through a JavaScript package manager.
|
|
96
|
+
Install XDocs as a development dependency through a JavaScript package manager. Package-manager execution uses the shipped Bun launcher, which downloads the matching native binary during `postinstall` or on first run if the install hook did not run, then executes the native binary:
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
99
|
bun add -d @guiho/xdocs
|
|
@@ -105,7 +105,7 @@ Or with npm:
|
|
|
105
105
|
npm install -D @guiho/xdocs
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Use the direct installer when you do not want a JavaScript package manager involved. Use the package-manager install when you want project-local dependency management
|
|
108
|
+
Use the direct installer when you do not want a JavaScript package manager or Bun involved at runtime. Use the package-manager install when you want project-local dependency management or `bunx` execution; the shipped Bun launcher ensures the native binary exists and delegates to it.
|
|
109
109
|
|
|
110
110
|
## Quick Start
|
|
111
111
|
|
|
@@ -324,7 +324,7 @@ Optional. When present, must be `1`.
|
|
|
324
324
|
|
|
325
325
|
### `[agents]`
|
|
326
326
|
|
|
327
|
-
Agent settings control skill installation and the automation that runs on data commands.
|
|
327
|
+
Agent settings control skill installation and the automation that runs on bare and data commands.
|
|
328
328
|
|
|
329
329
|
- `auto_agents_md`: Keep the `AGENTS.md` xdocs section fresh on normal commands when `AGENTS.md` already exists. Default: `true`.
|
|
330
330
|
- `auto_skill_install`: Install or refresh the configured skill globally from the bundled package copy. Default: `true`.
|
|
@@ -349,12 +349,13 @@ The rule is: default to the standard target. Only write non-standard files (`.cl
|
|
|
349
349
|
|
|
350
350
|
### Automation
|
|
351
351
|
|
|
352
|
-
|
|
352
|
+
Bare `xdocs` invocations and the data commands (`scan`, `generate`, `merge`, `tree`, `list`) run agent automation before executing:
|
|
353
353
|
|
|
354
|
-
-
|
|
355
|
-
-
|
|
354
|
+
- XDocs always bootstraps the global skill with default settings when no config is present, using the standard `agents` target.
|
|
355
|
+
- When `xdocs.config.toml` is present and `auto_agents_md` is true, the xdocs section is kept fresh if `AGENTS.md` exists.
|
|
356
|
+
- When config is present and `auto_skill_install` is true, XDocs ensures the configured global skill is current from the bundled package copy, removing legacy skill names and printing a one-line notice to stderr when it installs or refreshes anything.
|
|
356
357
|
|
|
357
|
-
|
|
358
|
+
`--help` and `--version` stay read-only. `init` and `agents` do not run this automation; they manage agent files explicitly.
|
|
358
359
|
|
|
359
360
|
## AI Usage Workflow
|
|
360
361
|
|
|
@@ -507,7 +508,7 @@ Supported release asset matrix:
|
|
|
507
508
|
|
|
508
509
|
Windows arm64 is intentionally not published until Bun's compilation support is reliable enough for this project. Unsupported platforms should use a documented manual path: install Bun and run from source, or download a compatible release asset manually.
|
|
509
510
|
|
|
510
|
-
The package-manager install path
|
|
511
|
+
The package-manager install path ships `scripts/xdocs-bin.ts` as the package `bin`. That launcher calls `scripts/install-package.ts` during first run if `vendor/xdocs` or `vendor/xdocs.exe` is missing. The install helper downloads the matching GitHub Release asset, or copies a bundled asset when present. The native binary entrypoint embeds prompt templates, the `guiho-s-xdocs` skill, and package version metadata before importing the CLI, so installed binaries do not need adjacent prompt or skill files at runtime.
|
|
511
512
|
|
|
512
513
|
## Documentation Requirement Before Publishing
|
|
513
514
|
|
package/README.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
**Structured documentation system for codebases. Helps AI make sense of projects.**
|
|
4
4
|
|
|
5
|
+
**npm package:** [@guiho/xdocs](https://www.npmjs.com/package/@guiho/xdocs)
|
|
6
|
+
|
|
5
7
|
xdocs is a CLI and TypeScript library that places structured documentation files throughout your project so that AI agents (and humans) can navigate, understand, and work within a codebase without reading every file. Each xdocs file describes the directory it lives in -- its purpose, its files, and how it fits into the project hierarchy.
|
|
6
8
|
|
|
7
9
|
```text
|
|
8
10
|
codebase -> xdocs files -> AI understands the project
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
xdocs
|
|
13
|
+
xdocs ships as compiled native binaries, a thin Bun launcher for package-manager and `bunx` execution, and a fully-typed TypeScript library.
|
|
12
14
|
|
|
13
15
|
---
|
|
14
16
|
|
|
@@ -28,7 +30,7 @@ irm https://raw.githubusercontent.com/CGuiho/xdocs/main/install.ps1 | iex
|
|
|
28
30
|
|
|
29
31
|
Set `XDOCS_VERSION=0.2.3` (or the full tag `@guiho/xdocs@0.2.3`) before running an installer to pin a specific release instead of installing the latest.
|
|
30
32
|
|
|
31
|
-
Package-manager install (convenient for JavaScript projects; downloads the matching native binary during `postinstall`,
|
|
33
|
+
Package-manager install (convenient for JavaScript projects; downloads the matching native binary during `postinstall`, or on first run if the install hook did not run):
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
36
|
npm install -D @guiho/xdocs
|
|
@@ -36,7 +38,7 @@ npm install -D @guiho/xdocs
|
|
|
36
38
|
bun add -d @guiho/xdocs
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
Native release assets are published for Linux x64/arm64, macOS x64/arm64, and Windows x64. Windows arm64 is not published yet.
|
|
41
|
+
Native release assets are published for Linux x64/arm64, macOS x64/arm64, and Windows x64. Windows arm64 is not published yet. Direct installs run without Node.js or Bun at runtime. Package-manager and `bunx` execution use a shipped Bun launcher that ensures the matching native binary is installed, then delegates to it.
|
|
40
42
|
|
|
41
43
|
### Initializing
|
|
42
44
|
|
|
@@ -259,7 +261,7 @@ exclude = ["node_modules", ".git", "dist", "build", "library", "bin", "bundle"]
|
|
|
259
261
|
name = "my-project"
|
|
260
262
|
|
|
261
263
|
[agents]
|
|
262
|
-
# Keep the xdocs section in AGENTS.md fresh on normal commands. Default: true
|
|
264
|
+
# Keep the xdocs section in AGENTS.md fresh on bare and normal commands. Default: true
|
|
263
265
|
auto_agents_md = true
|
|
264
266
|
# Install or refresh the standard skill globally from the bundled copy. Default: true
|
|
265
267
|
auto_skill_install = true
|
|
@@ -286,6 +288,8 @@ xdocs agents instructions # insert/refresh the AGENTS.md section
|
|
|
286
288
|
|
|
287
289
|
`xdocs init` runs this automatically for the standard target (`local` scope). `local` scope installs under the project; `global` installs under your home directory. The default is always the standard target -- non-standard files are written only when you ask (`--tool`) or when they are already present. Installation removes legacy `guiho-as-xdocs` skill directories and replaces `guiho-s-xdocs` when the bundled version or content differs.
|
|
288
290
|
|
|
291
|
+
A bare `xdocs` invocation and the normal data commands refresh the global skill before doing their usual work. Without `xdocs.config.toml`, xdocs uses the standard `agents` target; with config, `[agents].skill_tool` can choose the target and `[agents].auto_skill_install = false` can disable the refresh. If the legacy `guiho-as-xdocs` skill exists for that global target, xdocs removes it and writes the bundled `guiho-s-xdocs` skill.
|
|
292
|
+
|
|
289
293
|
---
|
|
290
294
|
|
|
291
295
|
## API Reference
|
package/jsr.json
CHANGED
package/library/agents.d.ts
CHANGED
|
@@ -70,10 +70,9 @@ export declare const findAgentsFile: (cwd: string) => string | undefined;
|
|
|
70
70
|
/** Resolve agent settings from the discovered xdocs config (defaults when absent). */
|
|
71
71
|
export declare const resolveAgentSettings: (options: XDocsCliOptions) => Promise<XDocsAgentSettings>;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* the configured tool from the bundled package copy.
|
|
73
|
+
* Agent automation run by bare and data commands. It always bootstraps the
|
|
74
|
+
* configured global skill from the bundled package copy; when config exists,
|
|
75
|
+
* it also keeps the AGENTS.md section fresh if enabled and AGENTS.md exists.
|
|
77
76
|
*/
|
|
78
77
|
export declare const runAgentAutomation: (options: AgentAutomationOptions, notify?: (message: string) => void) => Promise<XDocsAgentAutomationResult>;
|
|
79
78
|
/** Read a skill version from SKILL.md YAML frontmatter. */
|
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,kBAAkB,CAAA;AAE7C,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAuB,CAAA;AAE1E;;iEAEiE;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAS5B,CAAA;AAEJ,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,oBAAsC,CAAA;AAEpE,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,EAK5D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,KAAG,cAAc,EAChC,CAAA;AAkB9D,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,mhCAoBV,CAAA;AAErB,KAAK,g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AAO7D,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,CA6BjC,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;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,sBAAsB,EAC/B,SAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,KAC3C,OAAO,CAAC,0BAA0B,CAgBpC,CAAA;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE"}
|
package/library/agents.js
CHANGED
|
@@ -208,19 +208,16 @@ export const resolveAgentSettings = async (options) => {
|
|
|
208
208
|
return normalizeAgentSettings(discovered.raw?.agents);
|
|
209
209
|
};
|
|
210
210
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* the configured tool from the bundled package copy.
|
|
211
|
+
* Agent automation run by bare and data commands. It always bootstraps the
|
|
212
|
+
* configured global skill from the bundled package copy; when config exists,
|
|
213
|
+
* it also keeps the AGENTS.md section fresh if enabled and AGENTS.md exists.
|
|
215
214
|
*/
|
|
216
215
|
export const runAgentAutomation = async (options, notify = () => { }) => {
|
|
217
216
|
const cwd = resolve(options.cwd);
|
|
218
217
|
const discovered = await discoverConfig(cwd, options.config);
|
|
219
|
-
|
|
220
|
-
return { settings: { ...normalizeAgentSettings(undefined) } };
|
|
221
|
-
const settings = normalizeAgentSettings(discovered.raw.agents);
|
|
218
|
+
const settings = normalizeAgentSettings(discovered.raw?.agents);
|
|
222
219
|
const result = { settings };
|
|
223
|
-
if (settings.autoAgentsMd)
|
|
220
|
+
if (discovered.raw && settings.autoAgentsMd)
|
|
224
221
|
result.agentsMd = await ensureAgentsInstructions(cwd, false);
|
|
225
222
|
if (settings.autoSkillInstall) {
|
|
226
223
|
const globalSkill = await installSkill(settings.skillTool, 'global', { cwd, homeDirectory: options.homeDirectory });
|
package/library/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsBH,4BAA4B;AAC5B,eAAO,MAAM,MAAM,GAAU,UAAS,MAAM,EAA0B,KAAG,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsBH,4BAA4B;AAC5B,eAAO,MAAM,MAAM,GAAU,UAAS,MAAM,EAA0B,KAAG,OAAO,CAAC,IAAI,CA6DpF,CAAA;AAmBD,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,GAAU,UAAU,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAiB9E,CAAA"}
|
package/library/cli.js
CHANGED
|
@@ -33,14 +33,15 @@ export const runCli = async (rawArgs = process.argv.slice(2)) => {
|
|
|
33
33
|
}
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
+
if (parsed.command && !validCommands.has(parsed.command)) {
|
|
37
|
+
throw new XDocsError(`Unknown command: ${parsed.command}\n\nRun \`xdocs --help\` for available commands.`);
|
|
38
|
+
}
|
|
39
|
+
const options = resolveOptions(parsed.flags);
|
|
36
40
|
if (!parsed.command) {
|
|
41
|
+
await runAgentAutomation(options, (message) => process.stderr.write(message + '\n'));
|
|
37
42
|
process.stdout.write(showHelp() + '\n');
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
40
|
-
if (!validCommands.has(parsed.command)) {
|
|
41
|
-
throw new XDocsError(`Unknown command: ${parsed.command}\n\nRun \`xdocs --help\` for available commands.`);
|
|
42
|
-
}
|
|
43
|
-
const options = resolveOptions(parsed.flags);
|
|
44
45
|
const command = parsed.command;
|
|
45
46
|
if (automationCommands.has(command)) {
|
|
46
47
|
await runAgentAutomation(options, (message) => process.stderr.write(message + '\n'));
|
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.3.
|
|
4
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"binary": "bun build source/guiho-xdocs-native-bin.ts --compile --outfile bin/xdocs",
|
|
50
50
|
"binaries": "bun run devops/build-binaries.ts",
|
|
51
51
|
"bundle": "rm -rf bundle && bun build source/guiho-xdocs-bin.ts --outdir bundle --target node --sourcemap=linked",
|
|
52
|
-
"postinstall": "
|
|
52
|
+
"postinstall": "bun run scripts/install-package.ts",
|
|
53
53
|
"typecheck": "tsc -p . --noEmit",
|
|
54
54
|
"clean": "rm -rf .temp",
|
|
55
55
|
"clean-build": "rm -rf build library bundle bin",
|
|
@@ -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,10 +1,11 @@
|
|
|
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.
|
|
8
9
|
tags:
|
|
9
10
|
- install
|
|
10
11
|
- native-binary
|
|
@@ -13,6 +14,7 @@ flags: []
|
|
|
13
14
|
status: stable
|
|
14
15
|
---
|
|
15
16
|
|
|
16
|
-
The `scripts/` directory contains package-manager
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
The `scripts/` directory contains the package-manager launcher and install
|
|
18
|
+
helper. Package-manager and `bunx` execution start in `xdocs-bin.ts`; if the
|
|
19
|
+
native binary is missing, it runs `install-package.ts` and then delegates to the
|
|
20
|
+
downloaded binary in `vendor/`. Direct installers remain the no-Bun runtime path.
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
* Small package-manager launcher for the downloaded native xdocs binary.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const binaryPath = new URL(`../vendor/xdocs${process.platform === 'win32' ? '.exe' : ''}`, import.meta.url)
|
|
9
|
+
const executablePath = Bun.fileURLToPath(binaryPath)
|
|
10
|
+
const binary = Bun.file(binaryPath)
|
|
11
|
+
|
|
12
|
+
if (!(await binary.exists())) {
|
|
13
|
+
const installerPath = new URL('install-package.ts', import.meta.url)
|
|
14
|
+
const proc = Bun.spawn([process.execPath, Bun.fileURLToPath(installerPath)], {
|
|
15
|
+
stdin: 'inherit',
|
|
16
|
+
stdout: 'inherit',
|
|
17
|
+
stderr: 'inherit',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const exitCode = await proc.exited
|
|
21
|
+
if (exitCode !== 0 || !(await Bun.file(binaryPath).exists())) {
|
|
22
|
+
console.error('error: xdocs native binary is missing. Reinstall @guiho/xdocs or run `bun run scripts/install-package.ts`.')
|
|
23
|
+
process.exit(exitCode || 1)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const proc = Bun.spawn([executablePath, ...process.argv.slice(2)], {
|
|
28
|
+
stdin: 'inherit',
|
|
29
|
+
stdout: 'inherit',
|
|
30
|
+
stderr: 'inherit',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
process.exit(await proc.exited)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: guiho-s-xdocs
|
|
3
|
-
version: 0.3.0
|
|
3
|
+
version: 0.3.0
|
|
4
4
|
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.
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -178,12 +178,12 @@ exclude = ["node_modules", ".git", "dist", "build", "library", "bin", "bundle"]
|
|
|
178
178
|
name = "my-project"
|
|
179
179
|
|
|
180
180
|
[agents]
|
|
181
|
-
auto_agents_md = true # keep the xdocs section in AGENTS.md up to date on normal commands
|
|
181
|
+
auto_agents_md = true # keep the xdocs section in AGENTS.md up to date on bare and normal commands
|
|
182
182
|
auto_skill_install = true # install or refresh the guiho-s-xdocs skill globally
|
|
183
183
|
skill_tool = "agents" # default tool for auto-install: agents (standard) or claude
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
Agent automation options default to true.
|
|
186
|
+
Agent automation options default to true. A bare `xdocs` invocation and normal data commands always bootstrap the standard global skill when no config is present; with config, set `auto_agents_md = false` to stop xdocs from touching AGENTS.md, and `auto_skill_install = false` to stop xdocs from installing or refreshing `guiho-s-xdocs` globally.
|
|
187
187
|
|
|
188
188
|
## CLI Reference
|
|
189
189
|
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* Install the platform-native xdocs binary for package-manager installs.
|
|
4
|
-
* Node is used only during installation. The installed `xdocs` command points
|
|
5
|
-
* directly at the downloaded native binary and does not require Node at runtime.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { createWriteStream, existsSync, mkdirSync, chmodSync } = require('node:fs')
|
|
9
|
-
const { readFile } = require('node:fs/promises')
|
|
10
|
-
const { get } = require('node:https')
|
|
11
|
-
const { join } = require('node:path')
|
|
12
|
-
|
|
13
|
-
const root = join(__dirname, '..')
|
|
14
|
-
const packagePath = join(root, 'package.json')
|
|
15
|
-
const targetPath = join(root, 'bin', 'xdocs.exe')
|
|
16
|
-
|
|
17
|
-
main().catch((error) => {
|
|
18
|
-
console.error(`xdocs: failed to install native binary: ${error.message}`)
|
|
19
|
-
process.exit(1)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
async function main() {
|
|
23
|
-
if (process.env.XDOCS_SKIP_NATIVE_INSTALL === '1') {
|
|
24
|
-
console.warn('xdocs: skipping native binary installation because XDOCS_SKIP_NATIVE_INSTALL=1')
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (existsSync(join(root, 'source'))) {
|
|
29
|
-
console.warn('xdocs: skipping native binary installation in a source checkout')
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const packageJson = JSON.parse(await readFile(packagePath, 'utf8'))
|
|
34
|
-
const version = packageJson.version
|
|
35
|
-
if (typeof version !== 'string' || version.length === 0) throw new Error('package.json version is missing')
|
|
36
|
-
|
|
37
|
-
const asset = assetName()
|
|
38
|
-
const tag = `@guiho/xdocs@${version}`
|
|
39
|
-
const url = `https://github.com/CGuiho/xdocs/releases/download/${encodeURIComponent(tag)}/${asset}`
|
|
40
|
-
|
|
41
|
-
mkdirSync(join(root, 'bin'), { recursive: true })
|
|
42
|
-
await download(url, targetPath)
|
|
43
|
-
if (process.platform !== 'win32') chmodSync(targetPath, 0o755)
|
|
44
|
-
|
|
45
|
-
console.log(`xdocs: installed native binary ${asset}`)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function assetName() {
|
|
49
|
-
if (process.platform === 'linux') {
|
|
50
|
-
if (process.arch === 'x64') return 'xdocs-linux-x64'
|
|
51
|
-
if (process.arch === 'arm64') return 'xdocs-linux-arm64'
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (process.platform === 'darwin') {
|
|
55
|
-
if (process.arch === 'x64') return 'xdocs-macos-x64'
|
|
56
|
-
if (process.arch === 'arm64') return 'xdocs-macos-arm64'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (process.platform === 'win32') {
|
|
60
|
-
if (process.arch === 'x64') return 'xdocs-windows-x64.exe'
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
throw new Error(`unsupported platform: ${process.platform}/${process.arch}`)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function download(url, destination) {
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
const request = get(url, (response) => {
|
|
69
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
70
|
-
const location = response.headers.location
|
|
71
|
-
if (!location) {
|
|
72
|
-
reject(new Error(`redirect from ${url} did not include a Location header`))
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
download(location, destination).then(resolve, reject)
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (response.statusCode !== 200) {
|
|
81
|
-
reject(new Error(`download failed (${response.statusCode}) from ${url}`))
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const file = createWriteStream(destination)
|
|
86
|
-
response.pipe(file)
|
|
87
|
-
file.on('finish', () => {
|
|
88
|
-
file.close(resolve)
|
|
89
|
-
})
|
|
90
|
-
file.on('error', reject)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
request.on('error', reject)
|
|
94
|
-
request.end()
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Keep npm pack from treating this package as broken before postinstall runs.
|
|
99
|
-
if (!existsSync(targetPath)) {
|
|
100
|
-
mkdirSync(join(root, 'bin'), { recursive: true })
|
|
101
|
-
}
|