@xh/hoist-docs 0.0.1 → 1.0.0-SNAPSHOT.1794425058316
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/README.md +9 -2
- package/dist/cli.js +35 -14
- package/dist/mcp.js +1 -0
- package/package.json +17 -18
package/README.md
CHANGED
|
@@ -59,7 +59,9 @@ and `version`. Fetched indexes are cached in `HOIST_DOCS_CACHE`. Without registr
|
|
|
59
59
|
instead (`--index-dir`, or `INDEX_DIR`), which may hold several versions of each library.
|
|
60
60
|
`GET /health` reports what is loaded. Browser requests are checked against allowed origins
|
|
61
61
|
(localhost, plus `ALLOWED_ORIGINS`, comma-separated); agents and gateways send no `Origin` and
|
|
62
|
-
pass.
|
|
62
|
+
pass. Each release publishes the `Dockerfile`'s image as `ghcr.io/xh/hoist-docs` (tags `X.Y.Z`,
|
|
63
|
+
`X.Y`, `X` and `latest`); its header lists the mounts and variables. To serve a directory instead,
|
|
64
|
+
set `INDEX_DIR` and mount it.
|
|
63
65
|
|
|
64
66
|
## Docs viewers
|
|
65
67
|
|
|
@@ -89,7 +91,8 @@ compiled (`pnpm build`, run automatically on pack).
|
|
|
89
91
|
pnpm install
|
|
90
92
|
pnpm build:react --root ../hoist-react # build indexes from sibling checkouts into ./indexes
|
|
91
93
|
pnpm build:core --root ../hoist-core
|
|
92
|
-
pnpm build:react --root ../hoist-chat-kit
|
|
94
|
+
pnpm build:react --root ../hoist-chat-kit
|
|
95
|
+
pnpm build:watch # rebuild ./indexes as the checkouts or builders change
|
|
93
96
|
pnpm dev # HTTP on 8081 from ./indexes, restarting on changes
|
|
94
97
|
pnpm mcp --index-dir indexes # stdio, as an agent would run it
|
|
95
98
|
```
|
|
@@ -144,3 +147,7 @@ The library also needs its docs and a `docs/doc-registry.json`. An XH library ge
|
|
|
144
147
|
workflow tests and publishes it.
|
|
145
148
|
- **The builders**, `@xh/hoist-docs-builder` on npm and `io.xh:hoist-docs-builder` on Maven
|
|
146
149
|
Central, publish from the same tag and workflow, at the same version.
|
|
150
|
+
- **Snapshots**: every push to `develop` publishes all three through the `Deploy Snapshot` workflow -
|
|
151
|
+
the npm packages as `<version>.<timestamp>` under the `next` dist-tag, the Grails builder as
|
|
152
|
+
`1.0.0-SNAPSHOT` to Sonatype's snapshot repository. Libraries depend on the builder's `next` (or,
|
|
153
|
+
for hoist-core, its `-SNAPSHOT`), so each of their builds uses the newest builder.
|
package/dist/cli.js
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* hoist-docs export-docs --out <dir> [--from-checkout <dir> ...]
|
|
17
17
|
* Write the docs part of the project's indexes, for a docs viewer
|
|
18
18
|
* such as Toolbox's (see `@xh/hoist-docs/docs`). With
|
|
19
|
-
* --from-checkout, read docs straight from
|
|
20
|
-
*
|
|
19
|
+
* --from-checkout, read docs straight from library checkouts
|
|
20
|
+
* instead, in a second or two - plus, with --project, the
|
|
21
|
+
* project's other installed libraries.
|
|
21
22
|
*
|
|
22
23
|
* Options: --project <dir> (default: current directory), --index-dir <dir> (serve or export the
|
|
23
24
|
* indexes in a directory instead of resolving the project's), --port <n> (HTTP), --help.
|
|
@@ -30,7 +31,7 @@ import { loadConfig } from './config.js';
|
|
|
30
31
|
import { extractDocs } from './docs/index.js';
|
|
31
32
|
import { IndexStore } from './IndexStore.js';
|
|
32
33
|
import { LibraryIndex } from './index/LibraryIndex.js';
|
|
33
|
-
import { libraryDef } from './libraries.js';
|
|
34
|
+
import { LIBRARIES, libraryDef } from './libraries.js';
|
|
34
35
|
import { IndexCache } from './local/cache.js';
|
|
35
36
|
import { docsFromCheckout } from './local/checkout.js';
|
|
36
37
|
import { findInstalledIndexes } from './local/installed.js';
|
|
@@ -49,9 +50,9 @@ const USAGE = `Usage:
|
|
|
49
50
|
MCP over HTTP, for MCP gateways and development.
|
|
50
51
|
hoist-docs export-docs --out <dir> [--project <dir>] [--index-dir <dir>]
|
|
51
52
|
Write docs payloads for a docs viewer, from the project's own Hoist versions.
|
|
52
|
-
hoist-docs export-docs --out <dir> --from-checkout <dir> [--from-checkout <dir>] [--watch]
|
|
53
|
-
Write docs payloads straight from
|
|
54
|
-
on every doc change, for live preview.`;
|
|
53
|
+
hoist-docs export-docs --out <dir> --from-checkout <dir> [--from-checkout <dir>] [--project <dir>] [--watch]
|
|
54
|
+
Write docs payloads straight from library checkouts - with --project, plus the project's other
|
|
55
|
+
installed libraries; with --watch, again on every doc change, for live preview.`;
|
|
55
56
|
/** Run the command. Exported for tests; `bin/hoist-docs.mjs` and `pnpm start` call it. */
|
|
56
57
|
export async function main(argv, deps = {}) {
|
|
57
58
|
const args = parseArgs(argv), config = loadConfig(process.env, packageVersion());
|
|
@@ -98,21 +99,27 @@ export async function main(argv, deps = {}) {
|
|
|
98
99
|
* The indexes to serve: an explicit directory (--index-dir, else a non-empty INDEX_DIR), else the
|
|
99
100
|
* project's own - every index its installed packages ship, plus hoist-core's from Maven. In a
|
|
100
101
|
* library checkout, libraries not installed there get their newest published snapshots.
|
|
102
|
+
*
|
|
103
|
+
* @param opts.skip - library ids not to resolve, e.g. those read from checkouts instead.
|
|
104
|
+
* @param opts.lenient - skip any library that fails with a warning, rather than only optional
|
|
105
|
+
* ones, and allow finding none.
|
|
101
106
|
*/
|
|
102
|
-
async function projectStore(args, deps) {
|
|
107
|
+
async function projectStore(args, deps, opts = {}) {
|
|
103
108
|
const indexDir = args.values['index-dir'] || process.env.INDEX_DIR;
|
|
104
109
|
if (indexDir)
|
|
105
110
|
return new IndexStore(indexDir);
|
|
106
|
-
const root = resolve(args.values.project ?? '.'), detected = detectProjectVersions(root), installed = findInstalledIndexes(root);
|
|
111
|
+
const root = resolve(args.values.project ?? '.'), skip = opts.skip ?? new Set(), detected = detectProjectVersions(root), installed = findInstalledIndexes(root);
|
|
107
112
|
[...detected.notes, ...installed.notes].forEach(note => log.warn(note));
|
|
108
|
-
const specs = installed.indexes
|
|
113
|
+
const specs = installed.indexes
|
|
114
|
+
.filter(i => !skip.has(i.libraryId))
|
|
115
|
+
.map(i => ({
|
|
109
116
|
libraryId: i.libraryId,
|
|
110
117
|
version: i.version,
|
|
111
118
|
path: i.path,
|
|
112
119
|
trusted: i.trusted
|
|
113
120
|
})), source = builtInSource(deps);
|
|
114
121
|
for (const [libraryId, version] of Object.entries(detected.versions)) {
|
|
115
|
-
if (specs.some(s => s.libraryId === libraryId))
|
|
122
|
+
if (skip.has(libraryId) || specs.some(s => s.libraryId === libraryId))
|
|
116
123
|
continue;
|
|
117
124
|
const lib = libraryDef(libraryId);
|
|
118
125
|
try {
|
|
@@ -132,12 +139,12 @@ async function projectStore(args, deps) {
|
|
|
132
139
|
catch (e) {
|
|
133
140
|
// hoist-react and hoist-core are what the tool is for, so their failure is fatal. An
|
|
134
141
|
// optional library is skipped, so it never costs the app the others.
|
|
135
|
-
if (!lib.optional)
|
|
142
|
+
if (!lib.optional && !opts.lenient)
|
|
136
143
|
throw e;
|
|
137
144
|
log.warn(`Skipping ${libraryId} ${version}: ${e.message}`);
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
|
-
if (!specs.length) {
|
|
147
|
+
if (!specs.length && !opts.lenient) {
|
|
141
148
|
throw new Error(`No Hoist versions found in ${root}: expected an installed @xh/hoist (client-app/node_modules) or hoistCoreVersion in gradle.properties. Run from the project root, or pass --project.`);
|
|
142
149
|
}
|
|
143
150
|
return new IndexStore(specs);
|
|
@@ -155,7 +162,17 @@ async function exportDocs(args, deps) {
|
|
|
155
162
|
if (!out)
|
|
156
163
|
throw new Error('export-docs needs --out <dir>');
|
|
157
164
|
if (args.checkouts.length) {
|
|
158
|
-
|
|
165
|
+
// With --project as well, libraries without a checkout come from the project's installed
|
|
166
|
+
// packages, so a developer with only some libraries checked out still gets all their docs.
|
|
167
|
+
const ids = args.checkouts.map(dir => docsFromCheckout(dir).library.id), installed = args.values.project
|
|
168
|
+
? await projectStore(args, deps, { skip: new Set(ids), lenient: true })
|
|
169
|
+
: null, fromProject = installed
|
|
170
|
+
?.libraryIds()
|
|
171
|
+
.filter(id => !ids.includes(id))
|
|
172
|
+
.map(id => extractDocs(LibraryIndex.readJson(installed.filePath(id)))) ?? [], write = () => writePayloads(out, [
|
|
173
|
+
...args.checkouts.map(dir => docsFromCheckout(dir)),
|
|
174
|
+
...fromProject
|
|
175
|
+
]);
|
|
159
176
|
write();
|
|
160
177
|
if (args.flags.has('watch'))
|
|
161
178
|
await watchCheckouts(args.checkouts, write);
|
|
@@ -168,7 +185,11 @@ async function exportDocs(args, deps) {
|
|
|
168
185
|
}
|
|
169
186
|
function writePayloads(out, payloads) {
|
|
170
187
|
mkdirSync(out, { recursive: true });
|
|
171
|
-
const
|
|
188
|
+
const rank = (p) => {
|
|
189
|
+
const i = LIBRARIES.findIndex(l => l.id === p.library.id);
|
|
190
|
+
return i < 0 ? LIBRARIES.length : i;
|
|
191
|
+
}, ordered = [...payloads].sort((a, b) => rank(a) - rank(b));
|
|
192
|
+
const manifest = ordered.map(payload => {
|
|
172
193
|
const { id, name, version } = payload.library, file = `${id}.json`;
|
|
173
194
|
writeFileSync(join(out, file), JSON.stringify(payload));
|
|
174
195
|
log.info('Exported docs', { library: id, version, file: join(out, file) });
|
package/dist/mcp.js
CHANGED
|
@@ -192,6 +192,7 @@ function instructions(store) {
|
|
|
192
192
|
return [
|
|
193
193
|
'Authoritative reference for the Hoist framework - @xh/hoist (hoist-react, client) and hoist-core (Grails server) - used when writing or modifying any code that consumes Hoist APIs, components, models, services, or patterns.',
|
|
194
194
|
'Do not guess at Hoist APIs, prop names, or framework conventions - consult these tools first. For how-to and concept questions start with hoist-search-docs, which returns ranked sections - read one with hoist-read-doc {id, section} rather than loading the whole doc; hoist-list-docs browses the catalog. For exact names, signatures, props, and config keys start with hoist-search-symbols: one strong keyword (an API name like GridModel or persistWith; camelCase names match their parts) returns one line per hit with its import path. Then call hoist-get-symbol for the import line, signature, JSDoc, and a member summary, and hoist-get-members with filter when you need member docs.',
|
|
195
|
+
'These tools show what an API promises, not how it works. When a question turns on runtime behavior - ordering, timing, defaults applied in code, edge cases, a suspected framework bug - or the docs and JSDoc leave it open, read the implementation rather than stopping at the reference. Symbol results give each file path within its library: @xh/hoist ships its TypeScript source in node_modules/@xh/hoist, and a sibling checkout of a library (e.g. ../hoist-react, ../hoist-core) is the place to read it when one exists; otherwise hoist-core source is at github.com/xh/hoist-core.',
|
|
195
196
|
`Libraries loaded: ${libs.map(l => `${l.id} (${l.name} ${l.version})`).join(', ')}. Every tool searches all of them unless you pass library: ${choice}. ${versionNote} hoist-core doc ids carry a "core:" prefix (core:docs/caching.md)${prefixes}.`,
|
|
196
197
|
...others
|
|
197
198
|
.filter(l => l.instructions)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist-docs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-SNAPSHOT.1794425058316",
|
|
4
4
|
"description": "Hoist documentation and API reference for AI coding agents, over MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,21 +31,6 @@
|
|
|
31
31
|
"README.md",
|
|
32
32
|
"LICENSE.md"
|
|
33
33
|
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"start": "node src/cli.ts --http --index-dir indexes",
|
|
36
|
-
"dev": "node --watch src/cli.ts --http --index-dir indexes",
|
|
37
|
-
"mcp": "node src/cli.ts",
|
|
38
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
39
|
-
"prepack": "pnpm build",
|
|
40
|
-
"build:react": "node builders/react/cli/build-index.ts",
|
|
41
|
-
"build:core": "builders/core/build-index.sh",
|
|
42
|
-
"typecheck": "tsc",
|
|
43
|
-
"lint": "eslint . && prettier --check .",
|
|
44
|
-
"format": "prettier --write .",
|
|
45
|
-
"test": "vitest run",
|
|
46
|
-
"test:watch": "vitest",
|
|
47
|
-
"build:builder": "pnpm --filter @xh/hoist-docs-builder build"
|
|
48
|
-
},
|
|
49
34
|
"dependencies": {
|
|
50
35
|
"@modelcontextprotocol/server": "^2.4.0",
|
|
51
36
|
"minisearch": "^7.2.0"
|
|
@@ -60,5 +45,19 @@
|
|
|
60
45
|
"typescript": "^7.0.2",
|
|
61
46
|
"vitest": "^5.1.0"
|
|
62
47
|
},
|
|
63
|
-
"
|
|
64
|
-
|
|
48
|
+
"scripts": {
|
|
49
|
+
"start": "node src/cli.ts --http --index-dir indexes",
|
|
50
|
+
"dev": "node --watch src/cli.ts --http --index-dir indexes",
|
|
51
|
+
"mcp": "node src/cli.ts",
|
|
52
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
53
|
+
"build:react": "node builders/react/cli/build-index.ts",
|
|
54
|
+
"build:core": "builders/core/build-index.sh",
|
|
55
|
+
"build:watch": "node scripts/watch-indexes.ts",
|
|
56
|
+
"typecheck": "tsc",
|
|
57
|
+
"lint": "eslint . && prettier --check .",
|
|
58
|
+
"format": "prettier --write .",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"build:builder": "pnpm --filter @xh/hoist-docs-builder build"
|
|
62
|
+
}
|
|
63
|
+
}
|