@astryxdesign/cli 0.6.5-canary.bfb918a → 0.6.5-canary.c2a49ec
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 +2 -2
- package/api/build/_adapter.d.mts +14 -0
- package/api/build/_adapter.mjs +58 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/kit/kit.mjs +39 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +132 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +44 -1
- package/api/docs/docs.type.d.mts +38 -1
- package/api/docs/docs.type.mjs +18 -1
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +146 -23
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +12 -2
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-theme.mjs +93 -3
- package/api/integration/add-theme.test.mjs +100 -0
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/search/search.d.mts +12 -5
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +123 -53
- package/api/search/search.test.mjs +123 -8
- package/api/search/search.type.d.mts +5 -5
- package/api/search/search.type.mjs +5 -5
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +146 -69
- package/api/theme/build/build.test.mjs +190 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +14 -3
- package/assets/docs/theme.doc.mjs +2 -1
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/clients/cli/commands/build-theme.mjs +8 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +222 -5
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +60 -16
- package/clients/cli/commands/theme-list.behavior.test.mjs +41 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +8 -0
- package/foundation/discovery/theme-discovery.d.mts +6 -0
- package/foundation/discovery/theme-discovery.mjs +9 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1 -1
- package/package.json +9 -9
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -25,7 +25,8 @@ export const doc = {
|
|
|
25
25
|
'ones the project\'s configured integrations contribute, including any ' +
|
|
26
26
|
'topic an integration replaces or extends, so it depends on the cwd. ' +
|
|
27
27
|
'A route opens a node of the docs tree instead: a namespace such as ' +
|
|
28
|
-
|
|
28
|
+
'`cli/api` returns its children one level down (`depth` reads as many ' +
|
|
29
|
+
'levels as asked, and `detail` how much of each doc below), a typed doc such as ' +
|
|
29
30
|
"`cli/api/functions/search` returns its content, and a guide the tree " +
|
|
30
31
|
'places (`cli/integrations/quick-start`) reads like any topic. ' +
|
|
31
32
|
'Every read but the list carries `links`, the commands that move from it: ' +
|
|
@@ -82,6 +83,18 @@ export const doc = {
|
|
|
82
83
|
description:
|
|
83
84
|
"Return the topic's section index (each section's key, title, and summary), even for a topic with one section.",
|
|
84
85
|
},
|
|
86
|
+
{
|
|
87
|
+
name: 'options.depth',
|
|
88
|
+
type: "number | 'all'",
|
|
89
|
+
description:
|
|
90
|
+
"How many levels below a docs-tree namespace to read: 0 for the namespace alone, 1 for its children (the default), 'all' for every level. Where a read stops, a child with docs below it carries childCount. A doc with nothing below it reads the same at any depth.",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'options.detail',
|
|
94
|
+
type: "'brief' | 'compact' | 'full'",
|
|
95
|
+
description:
|
|
96
|
+
"How much of each doc below the named one a depth read returns: brief (the default) is its identity; compact and full add its text (a guide's sections, a namespace's or typed doc's content). Given alone, it reads one level down.",
|
|
97
|
+
},
|
|
85
98
|
{
|
|
86
99
|
name: 'options.cwd',
|
|
87
100
|
type: 'string',
|
|
@@ -113,10 +126,18 @@ export const doc = {
|
|
|
113
126
|
{
|
|
114
127
|
type: 'docs.node',
|
|
115
128
|
description:
|
|
116
|
-
"A namespace or typed doc in the docs tree, read by its route: {id, route, kind, package, title, summary, breadcrumb, slots, content}. A namespace lists each slot's children one level down; a typed doc carries its content.",
|
|
129
|
+
"A namespace or typed doc in the docs tree, read by its route: {id, route, kind, package, title, summary, breadcrumb, slots, content}. A namespace lists each slot's children one level down, or as deep as depth asks, each child carrying its own slots, childCount where the read stops, and its text at compact or full detail; a typed doc carries its content.",
|
|
117
130
|
},
|
|
118
131
|
],
|
|
119
132
|
throws: [
|
|
133
|
+
{
|
|
134
|
+
code: 'ERR_INVALID_ARGUMENT',
|
|
135
|
+
when: "depth is not a whole number of levels or 'all'",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: 'ERR_INVALID_DETAIL',
|
|
139
|
+
when: 'detail is not brief, compact, or full',
|
|
140
|
+
},
|
|
120
141
|
{
|
|
121
142
|
code: 'ERR_UNKNOWN_TOPIC',
|
|
122
143
|
when: 'the topic is not a string, or matches no topic and no docs-tree route',
|
|
@@ -134,6 +155,14 @@ export const doc = {
|
|
|
134
155
|
code: "await docs('principles', undefined, {index: true});",
|
|
135
156
|
},
|
|
136
157
|
{label: 'A docs-tree namespace', code: "await docs('cli/api');"},
|
|
158
|
+
{
|
|
159
|
+
label: 'Every doc below a namespace, one entry each',
|
|
160
|
+
code: "await docs('cli', undefined, {depth: 'all'});",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
label: 'A namespace and everything below it, in full',
|
|
164
|
+
code: "await docs('cli/integrations', undefined, {depth: 'all', detail: 'full'});",
|
|
165
|
+
},
|
|
137
166
|
{label: 'One API function', code: "await docs('cli/api/functions/search');"},
|
|
138
167
|
{
|
|
139
168
|
label: 'A whole guide from the docs tree',
|
package/api/docs/docs.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* docs(topic, undefined, {index: true}) -> index -> docs.index
|
|
12
12
|
* docs(topic, section) -> section -> docs.detail.section
|
|
13
13
|
* docs(route) -> node -> docs.node
|
|
14
|
+
* docs(route, undefined, {depth: 2}) -> node -> docs.node, two levels
|
|
14
15
|
*
|
|
15
16
|
* A topic read returns the whole doc, as it always has; `index` returns its
|
|
16
17
|
* sections, so a reader can open one by its key (spec:AST-047). The CLI's text
|
|
@@ -33,6 +34,43 @@ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
|
33
34
|
|
|
34
35
|
export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
|
|
35
36
|
|
|
37
|
+
const DETAILS = ['brief', 'compact', 'full'];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* How far a docs-tree read goes, from the options: `depth` levels below the
|
|
41
|
+
* node, or every level for `'all'`, and `detail` for each doc below it (brief
|
|
42
|
+
* by default). `detail` alone reads one level down. Neither: the plain read.
|
|
43
|
+
* @param {import('./docs.type.mjs').DocsOptions} options
|
|
44
|
+
* @returns {import('./node/node.mjs').DepthRead | undefined}
|
|
45
|
+
*/
|
|
46
|
+
function depthRead(options) {
|
|
47
|
+
const {depth, detail} = options;
|
|
48
|
+
if (detail != null && !DETAILS.includes(detail)) {
|
|
49
|
+
throw new AstryxError(
|
|
50
|
+
`detail is brief, compact, or full, not ${JSON.stringify(detail)}.`,
|
|
51
|
+
undefined,
|
|
52
|
+
ERROR_CODES.ERR_INVALID_DETAIL,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (
|
|
56
|
+
depth != null &&
|
|
57
|
+
depth !== 'all' &&
|
|
58
|
+
!(Number.isInteger(depth) && /** @type {number} */ (depth) >= 0)
|
|
59
|
+
) {
|
|
60
|
+
throw new AstryxError(
|
|
61
|
+
`depth is a number of levels (0, 1, 2, ...) or "all", not ${JSON.stringify(depth)}.`,
|
|
62
|
+
undefined,
|
|
63
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (depth == null && detail == null) return undefined;
|
|
67
|
+
return {
|
|
68
|
+
depth: depth === 'all' ? Infinity : (depth ?? 1),
|
|
69
|
+
detail: /** @type {'brief' | 'compact' | 'full'} */ (detail ?? 'brief'),
|
|
70
|
+
lang: options.lang || (options.dense ? 'dense' : options.zh ? 'zh' : null),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
36
74
|
/**
|
|
37
75
|
* @param {string} [topic]
|
|
38
76
|
* @param {string} [section]
|
|
@@ -42,6 +80,10 @@ export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
|
|
|
42
80
|
* @param {boolean} [options.dense]
|
|
43
81
|
* @param {boolean} [options.index] return the topic's section index instead of
|
|
44
82
|
* the whole doc
|
|
83
|
+
* @param {number | 'all'} [options.depth] how many levels below a docs-tree
|
|
84
|
+
* namespace to read; a doc with nothing below it reads the same at any depth
|
|
85
|
+
* @param {'brief' | 'compact' | 'full'} [options.detail] how much of each doc
|
|
86
|
+
* below the named one a depth read returns (brief by default)
|
|
45
87
|
* @param {string} [options.cwd]
|
|
46
88
|
* @returns {Promise<
|
|
47
89
|
* import('./docs.type.mjs').DocsListResponse |
|
|
@@ -52,6 +94,7 @@ export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
|
|
|
52
94
|
* >}
|
|
53
95
|
*/
|
|
54
96
|
export async function docs(topic, section, options = {}) {
|
|
97
|
+
const read = depthRead(options);
|
|
55
98
|
if (!topic) return list(options);
|
|
56
99
|
const found = await resolveDocsArgument(topic, options);
|
|
57
100
|
if (found.kind === 'node') {
|
|
@@ -77,7 +120,7 @@ export async function docs(topic, section, options = {}) {
|
|
|
77
120
|
}
|
|
78
121
|
return {
|
|
79
122
|
type: 'docs.node',
|
|
80
|
-
data: await nodeView(found.catalog, found.tree, found.node),
|
|
123
|
+
data: await nodeView(found.catalog, found.tree, found.node, read),
|
|
81
124
|
};
|
|
82
125
|
}
|
|
83
126
|
if (section) return sectionLeaf(topic, section, options);
|
package/api/docs/docs.type.d.mts
CHANGED
|
@@ -205,9 +205,14 @@ export type DocsNode = {
|
|
|
205
205
|
breadcrumb: DocsNodeLink[];
|
|
206
206
|
/**
|
|
207
207
|
* a namespace's slots that hold children, in
|
|
208
|
-
* order; empty for a typed doc
|
|
208
|
+
* order; empty for a typed doc, and for a depth read of 0
|
|
209
209
|
*/
|
|
210
210
|
slots: DocsNodeSlot[];
|
|
211
|
+
/**
|
|
212
|
+
* with a depth read of 0, how many docs sit
|
|
213
|
+
* right below the namespace
|
|
214
|
+
*/
|
|
215
|
+
childCount?: number | undefined;
|
|
211
216
|
/**
|
|
212
217
|
* a typed doc's content; empty for a namespace
|
|
213
218
|
*/
|
|
@@ -246,6 +251,26 @@ export type DocsNodeChild = {
|
|
|
246
251
|
kind: string;
|
|
247
252
|
title: string;
|
|
248
253
|
summary: string;
|
|
254
|
+
/**
|
|
255
|
+
* with a depth read, its own slots, while
|
|
256
|
+
* the read goes deeper
|
|
257
|
+
*/
|
|
258
|
+
slots?: DocsNodeSlot[] | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* with a depth read, how many docs sit right
|
|
261
|
+
* below it where the read stops
|
|
262
|
+
*/
|
|
263
|
+
childCount?: number | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* with a depth read at compact or full detail: a namespace's intro or a typed
|
|
266
|
+
* doc's content
|
|
267
|
+
*/
|
|
268
|
+
content?: import("@astryxdesign/cli/authoring").ReferenceContentBlock[] | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* with a depth read at compact or full
|
|
271
|
+
* detail: a guide's sections
|
|
272
|
+
*/
|
|
273
|
+
sections?: DocsReadSection[] | undefined;
|
|
249
274
|
};
|
|
250
275
|
/**
|
|
251
276
|
* Options for `docs()`.
|
|
@@ -259,6 +284,18 @@ export type DocsOptions = {
|
|
|
259
284
|
* whole doc
|
|
260
285
|
*/
|
|
261
286
|
index?: boolean | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* how many levels below a docs-tree
|
|
289
|
+
* namespace to read: 0 for the namespace alone, 1 for its children (the
|
|
290
|
+
* default), 'all' for every level
|
|
291
|
+
*/
|
|
292
|
+
depth?: number | "all" | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* how much of each doc below
|
|
295
|
+
* the named one a depth read returns: brief (the default) is its identity,
|
|
296
|
+
* compact and full add its text
|
|
297
|
+
*/
|
|
298
|
+
detail?: "compact" | "full" | "brief" | undefined;
|
|
262
299
|
/**
|
|
263
300
|
* project directory whose configured integrations
|
|
264
301
|
* contribute topics; defaults to process.cwd()
|
package/api/docs/docs.type.mjs
CHANGED
|
@@ -153,7 +153,9 @@
|
|
|
153
153
|
* @property {string} summary
|
|
154
154
|
* @property {DocsNodeLink[]} breadcrumb the namespaces above it, top first
|
|
155
155
|
* @property {DocsNodeSlot[]} slots a namespace's slots that hold children, in
|
|
156
|
-
* order; empty for a typed doc
|
|
156
|
+
* order; empty for a typed doc, and for a depth read of 0
|
|
157
|
+
* @property {number} [childCount] with a depth read of 0, how many docs sit
|
|
158
|
+
* right below the namespace
|
|
157
159
|
* @property {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} content
|
|
158
160
|
* a typed doc's content; empty for a namespace
|
|
159
161
|
* @property {DocsLinks} links the moves from the node: up to its parent (the
|
|
@@ -181,6 +183,15 @@
|
|
|
181
183
|
* @property {string} kind
|
|
182
184
|
* @property {string} title
|
|
183
185
|
* @property {string} summary
|
|
186
|
+
* @property {DocsNodeSlot[]} [slots] with a depth read, its own slots, while
|
|
187
|
+
* the read goes deeper
|
|
188
|
+
* @property {number} [childCount] with a depth read, how many docs sit right
|
|
189
|
+
* below it where the read stops
|
|
190
|
+
* @property {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} [content]
|
|
191
|
+
* with a depth read at compact or full detail: a namespace's intro or a typed
|
|
192
|
+
* doc's content
|
|
193
|
+
* @property {DocsReadSection[]} [sections] with a depth read at compact or full
|
|
194
|
+
* detail: a guide's sections
|
|
184
195
|
*/
|
|
185
196
|
|
|
186
197
|
/**
|
|
@@ -191,6 +202,12 @@
|
|
|
191
202
|
* @property {boolean} [dense]
|
|
192
203
|
* @property {boolean} [index] return a topic's section index instead of its
|
|
193
204
|
* whole doc
|
|
205
|
+
* @property {number | 'all'} [depth] how many levels below a docs-tree
|
|
206
|
+
* namespace to read: 0 for the namespace alone, 1 for its children (the
|
|
207
|
+
* default), 'all' for every level
|
|
208
|
+
* @property {'brief' | 'compact' | 'full'} [detail] how much of each doc below
|
|
209
|
+
* the named one a depth read returns: brief (the default) is its identity,
|
|
210
|
+
* compact and full add its text
|
|
194
211
|
* @property {string} [cwd] project directory whose configured integrations
|
|
195
212
|
* contribute topics; defaults to process.cwd()
|
|
196
213
|
*/
|
package/api/docs/node/node.d.mts
CHANGED
|
@@ -4,15 +4,28 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
|
|
6
6
|
* @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
|
|
7
|
+
* @typedef {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} DocsCatalog
|
|
7
8
|
*/
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* How far a read goes below the node it names, and how much of each doc below
|
|
11
|
+
* it shows: `depth` levels (Infinity for every level), and `detail` brief (its
|
|
12
|
+
* identity), or compact or full (with its text: a namespace's intro, a guide's
|
|
13
|
+
* sections, a typed doc's content). `lang` selects the guides' language.
|
|
14
|
+
* @typedef {object} DepthRead
|
|
15
|
+
* @property {number} depth
|
|
16
|
+
* @property {'brief' | 'compact' | 'full'} detail
|
|
17
|
+
* @property {string | null} lang
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The docs.node view of one tree node. Without a depth read, a namespace lists
|
|
21
|
+
* its children one level down.
|
|
22
|
+
* @param {DocsCatalog} catalog
|
|
11
23
|
* @param {DocsTree} tree
|
|
12
24
|
* @param {TreeNode} node
|
|
25
|
+
* @param {DepthRead} [read] how far down to go, and how much of each doc below
|
|
13
26
|
* @returns {Promise<import('../docs.type.mjs').DocsNode>}
|
|
14
27
|
*/
|
|
15
|
-
export function nodeView(catalog:
|
|
28
|
+
export function nodeView(catalog: DocsCatalog, tree: DocsTree, node: TreeNode, read?: DepthRead): Promise<import("../docs.type.mjs").DocsNode>;
|
|
16
29
|
/**
|
|
17
30
|
* The typed edges a doc declares (spec:AST-047 FR5), resolved to routes: a
|
|
18
31
|
* function doc's `command` and `related`, and a command doc's `fn` and
|
|
@@ -41,3 +54,15 @@ export function node(route: string, options?: {
|
|
|
41
54
|
}): Promise<import("../docs.type.mjs").DocsNodeResponse>;
|
|
42
55
|
export type DocsTree = import("../../../foundation/doc-compiler/tree.mjs").DocsTree;
|
|
43
56
|
export type TreeNode = import("../../../foundation/doc-compiler/tree.mjs").TreeNode;
|
|
57
|
+
export type DocsCatalog = import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog;
|
|
58
|
+
/**
|
|
59
|
+
* How far a read goes below the node it names, and how much of each doc below
|
|
60
|
+
* it shows: `depth` levels (Infinity for every level), and `detail` brief (its
|
|
61
|
+
* identity), or compact or full (with its text: a namespace's intro, a guide's
|
|
62
|
+
* sections, a typed doc's content). `lang` selects the guides' language.
|
|
63
|
+
*/
|
|
64
|
+
export type DepthRead = {
|
|
65
|
+
depth: number;
|
|
66
|
+
detail: "brief" | "compact" | "full";
|
|
67
|
+
lang: string | null;
|
|
68
|
+
};
|
package/api/docs/node/node.mjs
CHANGED
|
@@ -7,14 +7,18 @@
|
|
|
7
7
|
* typed doc such as `cli/api/functions/search`, plus {cwd}.
|
|
8
8
|
* @output { type: 'docs.node', data: DocsNode } — the node's identity, title
|
|
9
9
|
* and summary, the namespaces above it, and either its slots with their
|
|
10
|
-
* children (a namespace) or its content (a typed doc).
|
|
11
|
-
* lists its
|
|
12
|
-
*
|
|
10
|
+
* children (a namespace) or its content (a typed doc). By default a
|
|
11
|
+
* namespace lists its children one level down; a depth read goes as far
|
|
12
|
+
* down as asked, with each doc below as its identity (brief) or with its
|
|
13
|
+
* text (compact, full). Matches `astryx --json docs <route> [--depth <n>]`.
|
|
13
14
|
* @position Leaf under api/docs, beside the topic leaves. A guide the tree
|
|
14
15
|
* places is a topic: the detail leaf reads it by its route.
|
|
15
16
|
*/
|
|
16
17
|
|
|
18
|
+
import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
|
|
17
19
|
import {
|
|
20
|
+
compileTopic,
|
|
21
|
+
guideEntry,
|
|
18
22
|
nodeContent,
|
|
19
23
|
placeLinks,
|
|
20
24
|
resolveDocsArgument,
|
|
@@ -24,18 +28,34 @@ import {
|
|
|
24
28
|
/**
|
|
25
29
|
* @typedef {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
|
|
26
30
|
* @typedef {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
|
|
31
|
+
* @typedef {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} DocsCatalog
|
|
27
32
|
*/
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
35
|
+
* How far a read goes below the node it names, and how much of each doc below
|
|
36
|
+
* it shows: `depth` levels (Infinity for every level), and `detail` brief (its
|
|
37
|
+
* identity), or compact or full (with its text: a namespace's intro, a guide's
|
|
38
|
+
* sections, a typed doc's content). `lang` selects the guides' language.
|
|
39
|
+
* @typedef {object} DepthRead
|
|
40
|
+
* @property {number} depth
|
|
41
|
+
* @property {'brief' | 'compact' | 'full'} detail
|
|
42
|
+
* @property {string | null} lang
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The docs.node view of one tree node. Without a depth read, a namespace lists
|
|
47
|
+
* its children one level down.
|
|
48
|
+
* @param {DocsCatalog} catalog
|
|
32
49
|
* @param {DocsTree} tree
|
|
33
50
|
* @param {TreeNode} node
|
|
51
|
+
* @param {DepthRead} [read] how far down to go, and how much of each doc below
|
|
34
52
|
* @returns {Promise<import('../docs.type.mjs').DocsNode>}
|
|
35
53
|
*/
|
|
36
|
-
export async function nodeView(catalog, tree, node) {
|
|
54
|
+
export async function nodeView(catalog, tree, node, read) {
|
|
37
55
|
const {content} = await nodeContent(catalog, tree, node);
|
|
38
|
-
|
|
56
|
+
const slots = node.slots.filter(slot => slot.children.length > 0);
|
|
57
|
+
/** @type {import('../docs.type.mjs').DocsNode} */
|
|
58
|
+
const view = {
|
|
39
59
|
id: node.id,
|
|
40
60
|
route: node.route,
|
|
41
61
|
kind: node.kind,
|
|
@@ -45,25 +65,128 @@ export async function nodeView(catalog, tree, node) {
|
|
|
45
65
|
breadcrumb: tree
|
|
46
66
|
.ancestors(node)
|
|
47
67
|
.map(ancestor => ({route: ancestor.route, title: ancestor.title})),
|
|
48
|
-
slots:
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
title: child.title,
|
|
60
|
-
summary: child.summary,
|
|
61
|
-
};
|
|
62
|
-
}),
|
|
63
|
-
})),
|
|
68
|
+
slots: !read
|
|
69
|
+
? slots.map(slot => ({
|
|
70
|
+
name: slot.name,
|
|
71
|
+
title: slot.title,
|
|
72
|
+
children: slot.children.map(route =>
|
|
73
|
+
childIdentity(/** @type {TreeNode} */ (tree.get(route))),
|
|
74
|
+
),
|
|
75
|
+
}))
|
|
76
|
+
: read.depth >= 1
|
|
77
|
+
? await slotsBelow(catalog, tree, slots, 1, read)
|
|
78
|
+
: [],
|
|
64
79
|
content,
|
|
65
80
|
links: nodeLinks(tree, node),
|
|
66
81
|
};
|
|
82
|
+
if (read && read.depth < 1 && slots.length > 0) {
|
|
83
|
+
view.childCount = countChildren(slots);
|
|
84
|
+
}
|
|
85
|
+
return view;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The fields every child carries: what it is, and the route that opens it.
|
|
90
|
+
* @param {TreeNode} child
|
|
91
|
+
* @returns {import('../docs.type.mjs').DocsNodeChild}
|
|
92
|
+
*/
|
|
93
|
+
function childIdentity(child) {
|
|
94
|
+
return {
|
|
95
|
+
route: child.route,
|
|
96
|
+
name: child.route.slice(child.route.lastIndexOf('/') + 1),
|
|
97
|
+
kind: child.kind,
|
|
98
|
+
title: child.title,
|
|
99
|
+
summary: child.summary,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {TreeNode['slots']} slots
|
|
105
|
+
* @returns {number}
|
|
106
|
+
*/
|
|
107
|
+
function countChildren(slots) {
|
|
108
|
+
return slots.reduce((count, slot) => count + slot.children.length, 0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Slots read `level` levels below the named node: each child at the read's
|
|
113
|
+
* detail, and its own slots while the read goes deeper.
|
|
114
|
+
* @param {DocsCatalog} catalog
|
|
115
|
+
* @param {DocsTree} tree
|
|
116
|
+
* @param {TreeNode['slots']} slots
|
|
117
|
+
* @param {number} level
|
|
118
|
+
* @param {DepthRead} read
|
|
119
|
+
* @returns {Promise<import('../docs.type.mjs').DocsNodeSlot[]>}
|
|
120
|
+
*/
|
|
121
|
+
async function slotsBelow(catalog, tree, slots, level, read) {
|
|
122
|
+
return Promise.all(
|
|
123
|
+
slots.map(async slot => ({
|
|
124
|
+
name: slot.name,
|
|
125
|
+
title: slot.title,
|
|
126
|
+
children: await Promise.all(
|
|
127
|
+
slot.children.map(route =>
|
|
128
|
+
childBelow(
|
|
129
|
+
catalog,
|
|
130
|
+
tree,
|
|
131
|
+
/** @type {TreeNode} */ (tree.get(route)),
|
|
132
|
+
level,
|
|
133
|
+
read,
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
),
|
|
137
|
+
})),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* One child of a depth read. Where the read stops, a child with docs below it
|
|
143
|
+
* says how many, so a reader knows to go deeper.
|
|
144
|
+
* @param {DocsCatalog} catalog
|
|
145
|
+
* @param {DocsTree} tree
|
|
146
|
+
* @param {TreeNode} child
|
|
147
|
+
* @param {number} level
|
|
148
|
+
* @param {DepthRead} read
|
|
149
|
+
* @returns {Promise<import('../docs.type.mjs').DocsNodeChild>}
|
|
150
|
+
*/
|
|
151
|
+
async function childBelow(catalog, tree, child, level, read) {
|
|
152
|
+
const view = childIdentity(child);
|
|
153
|
+
if (read.detail !== 'brief') {
|
|
154
|
+
Object.assign(view, await childText(catalog, tree, child, read.lang));
|
|
155
|
+
}
|
|
156
|
+
const slots = child.slots.filter(slot => slot.children.length > 0);
|
|
157
|
+
if (slots.length > 0) {
|
|
158
|
+
if (level < read.depth) {
|
|
159
|
+
view.slots = await slotsBelow(catalog, tree, slots, level + 1, read);
|
|
160
|
+
} else {
|
|
161
|
+
view.childCount = countChildren(slots);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return view;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* A child's text: a guide's compiled sections, or the content of a namespace
|
|
169
|
+
* or typed doc.
|
|
170
|
+
* @param {DocsCatalog} catalog
|
|
171
|
+
* @param {DocsTree} tree
|
|
172
|
+
* @param {TreeNode} child
|
|
173
|
+
* @param {string | null} lang
|
|
174
|
+
* @returns {Promise<{content?: any[], sections?: any[]}>}
|
|
175
|
+
*/
|
|
176
|
+
async function childText(catalog, tree, child, lang) {
|
|
177
|
+
if (child.kind === 'generic') {
|
|
178
|
+
const entry = child.ref?.topicFile
|
|
179
|
+
? guideEntry(child)
|
|
180
|
+
: child.ref?.flatTopic
|
|
181
|
+
? catalog.resolve(child.ref.flatTopic)
|
|
182
|
+
: null;
|
|
183
|
+
if (!entry) return {};
|
|
184
|
+
return {
|
|
185
|
+
sections: detailView(await compileTopic(catalog, entry, lang)).sections,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const {content} = await nodeContent(catalog, tree, child);
|
|
189
|
+
return {content};
|
|
67
190
|
}
|
|
68
191
|
|
|
69
192
|
/**
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Collect the effective handler set in delivery order: project config first,
|
|
6
6
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
7
|
-
* malformed integration exports
|
|
7
|
+
* malformed integration exports and integrations that failed to load retain
|
|
8
|
+
* their position as failed deliveries. An unloadable integration may export a
|
|
9
|
+
* handler, so it never counts as an empty set that enables the fallback.
|
|
8
10
|
*
|
|
9
11
|
* @param {Project} project
|
|
10
12
|
* @returns {HandlerEntry[]}
|
|
@@ -189,7 +189,9 @@ async function selectTarget(project, component, packageName) {
|
|
|
189
189
|
/**
|
|
190
190
|
* Collect the effective handler set in delivery order: project config first,
|
|
191
191
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
192
|
-
* malformed integration exports
|
|
192
|
+
* malformed integration exports and integrations that failed to load retain
|
|
193
|
+
* their position as failed deliveries. An unloadable integration may export a
|
|
194
|
+
* handler, so it never counts as an empty set that enables the fallback.
|
|
193
195
|
*
|
|
194
196
|
* @param {Project} project
|
|
195
197
|
* @returns {HandlerEntry[]}
|
|
@@ -214,7 +216,15 @@ export function collectGapReportHandlers(project) {
|
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
for (const integration of project.loadedIntegrations) {
|
|
217
|
-
if (integration.__loadError)
|
|
219
|
+
if (integration.__loadError) {
|
|
220
|
+
entries.push({
|
|
221
|
+
kind: 'malformed',
|
|
222
|
+
handlerType: 'integration',
|
|
223
|
+
handlerName: integration.name,
|
|
224
|
+
error: `Integration failed to load, so it could not receive this report: ${integration.__loadError}. Fix the package or remove it from integrations in astryx.config, then rerun.`,
|
|
225
|
+
});
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
218
228
|
if (integration.__gapReportError) {
|
|
219
229
|
entries.push({
|
|
220
230
|
kind: 'malformed',
|
|
@@ -105,6 +105,45 @@ function addIntegration({
|
|
|
105
105
|
return {dir};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Add an integration whose module throws on import, so it never loads.
|
|
110
|
+
* @param {string} name
|
|
111
|
+
*/
|
|
112
|
+
function addBrokenIntegration(name) {
|
|
113
|
+
const dir = packageDir(name);
|
|
114
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
115
|
+
fs.writeFileSync(
|
|
116
|
+
path.join(dir, 'package.json'),
|
|
117
|
+
JSON.stringify({name, version: '1.0.0', type: 'module'}),
|
|
118
|
+
);
|
|
119
|
+
fs.writeFileSync(
|
|
120
|
+
path.join(dir, 'astryx.integration.mjs'),
|
|
121
|
+
"throw new Error('intentional integration load failure');\n",
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Put a fake `gh` first on PATH that records its arguments if it is called.
|
|
127
|
+
* @returns {string} the file the fake writes when invoked
|
|
128
|
+
*/
|
|
129
|
+
function stubGh() {
|
|
130
|
+
const binDir = path.join(projectDir, 'bin');
|
|
131
|
+
const argsFile = path.join(projectDir, 'gh-args.json');
|
|
132
|
+
fs.mkdirSync(binDir, {recursive: true});
|
|
133
|
+
fs.writeFileSync(
|
|
134
|
+
path.join(binDir, 'gh'),
|
|
135
|
+
`#!/usr/bin/env node
|
|
136
|
+
import fs from 'node:fs';
|
|
137
|
+
fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
|
|
138
|
+
console.log('https://github.com/acme/core/issues/42');
|
|
139
|
+
`,
|
|
140
|
+
{mode: 0o755},
|
|
141
|
+
);
|
|
142
|
+
fs.chmodSync(path.join(binDir, 'gh'), 0o755);
|
|
143
|
+
vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
|
|
144
|
+
return argsFile;
|
|
145
|
+
}
|
|
146
|
+
|
|
108
147
|
const reportOptions = {
|
|
109
148
|
category: 'missing_variant',
|
|
110
149
|
reason: 'Need a compact size',
|
|
@@ -681,6 +720,73 @@ describe('gapReport handler isolation', () => {
|
|
|
681
720
|
});
|
|
682
721
|
});
|
|
683
722
|
|
|
723
|
+
it('an integration that fails to load is a failed delivery, not a missing handler', async () => {
|
|
724
|
+
addBrokenIntegration('@test/broken');
|
|
725
|
+
configure(['@test/broken'], {
|
|
726
|
+
issuesUrl: 'https://github.com/acme/core/issues/new',
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
const result = await gapReport('General', {
|
|
730
|
+
...reportOptions,
|
|
731
|
+
cwd: projectDir,
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
expect(result.data.status).toBe('failed');
|
|
735
|
+
expect(result.data.deliveries).toEqual([
|
|
736
|
+
{
|
|
737
|
+
handlerType: 'integration',
|
|
738
|
+
handler: '@test/broken',
|
|
739
|
+
audience: null,
|
|
740
|
+
status: 'failed',
|
|
741
|
+
url: null,
|
|
742
|
+
message: expect.stringContaining(
|
|
743
|
+
'intentional integration load failure',
|
|
744
|
+
),
|
|
745
|
+
},
|
|
746
|
+
]);
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
it('an integration that fails to load keeps the public fallback off, even with consent', async () => {
|
|
750
|
+
addBrokenIntegration('@test/broken');
|
|
751
|
+
configure(['@test/broken'], {
|
|
752
|
+
issuesUrl: 'https://github.com/acme/core/issues/new',
|
|
753
|
+
});
|
|
754
|
+
const argsFile = stubGh();
|
|
755
|
+
|
|
756
|
+
const result = await gapReport('General', {
|
|
757
|
+
...reportOptions,
|
|
758
|
+
confirmPublic: true,
|
|
759
|
+
cwd: projectDir,
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
expect(result.data.status).toBe('failed');
|
|
763
|
+
expect(result.data.deliveries.map(d => d.handlerType)).toEqual([
|
|
764
|
+
'integration',
|
|
765
|
+
]);
|
|
766
|
+
expect(fs.existsSync(argsFile)).toBe(false);
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
it('an integration that fails to load keeps its place beside working handlers', async () => {
|
|
770
|
+
addBrokenIntegration('@test/broken');
|
|
771
|
+
addIntegration({
|
|
772
|
+
name: '@test/valid',
|
|
773
|
+
audience: 'internal',
|
|
774
|
+
handleBody: "return {status: 'filed', message: 'ok'};",
|
|
775
|
+
});
|
|
776
|
+
configure(['@test/broken', '@test/valid']);
|
|
777
|
+
|
|
778
|
+
const result = await gapReport('General', {
|
|
779
|
+
...reportOptions,
|
|
780
|
+
cwd: projectDir,
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
expect(result.data.status).toBe('partial');
|
|
784
|
+
expect(result.data.deliveries.map(d => [d.handler, d.status])).toEqual([
|
|
785
|
+
['@test/broken', 'failed'],
|
|
786
|
+
['@test/valid', 'filed'],
|
|
787
|
+
]);
|
|
788
|
+
});
|
|
789
|
+
|
|
684
790
|
it('invalid handler receipt is recorded as failed delivery', async () => {
|
|
685
791
|
addIntegration({
|
|
686
792
|
name: '@test/bad-receipt',
|
package/api/hook/list/list.d.mts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export function list({ cwd, category, detail, zh, lang, }?: {
|
|
14
14
|
cwd?: string | undefined;
|
|
15
15
|
category?: string | undefined;
|
|
16
|
-
detail?: "compact" | "full" | "
|
|
16
|
+
detail?: "compact" | "full" | "brief" | "names" | undefined;
|
|
17
17
|
zh?: boolean | undefined;
|
|
18
18
|
lang?: string | null | undefined;
|
|
19
19
|
}): Promise<import("../hook.type.mjs").HookListResponse>;
|