@astryxdesign/cli 0.7.12-canary.f543ec7 → 0.7.12

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/api/build/blocks/blocks.d.mts +41 -0
  3. package/api/build/blocks/blocks.mjs +118 -68
  4. package/api/component/__fixtures__/resolutions/modules.txt +3 -3
  5. package/api/docs/_adapter.d.mts +22 -0
  6. package/api/docs/_adapter.mjs +81 -3
  7. package/api/docs/docs.doc.mjs +5 -5
  8. package/api/docs/docs.type.d.mts +21 -0
  9. package/api/docs/docs.type.mjs +11 -0
  10. package/api/docs/list/list.d.mts +5 -1
  11. package/api/docs/list/list.mjs +72 -6
  12. package/api/docs/node/node.mjs +2 -40
  13. package/api/doctor/doctor.d.mts +4 -4
  14. package/api/doctor/doctor.mjs +248 -78
  15. package/api/icon/_authoring.mjs +8 -1
  16. package/api/icon/add/add.mjs +45 -5
  17. package/api/icon/icon.type.d.mts +24 -0
  18. package/api/icon/icon.type.mjs +6 -0
  19. package/api/icon/iconAdd.doc.mjs +1 -1
  20. package/api/icon/map/map.mjs +11 -4
  21. package/api/index.d.mts +1 -0
  22. package/api/index.mjs +1 -0
  23. package/api/integration/add-helpers.d.mts +5 -1
  24. package/api/integration/add-helpers.mjs +1 -1
  25. package/api/render/_adapter.mjs +9 -0
  26. package/api/render/render.doc.mjs +3 -3
  27. package/api/render/render.type.d.mts +1 -1
  28. package/api/render/render.type.mjs +1 -1
  29. package/api/search/ORDERING.md +3 -0
  30. package/api/search/_adapter.d.mts +32 -3
  31. package/api/search/_adapter.mjs +50 -22
  32. package/api/search/_fit-order.d.mts +47 -0
  33. package/api/search/_fit-order.mjs +257 -0
  34. package/api/search/_main-searcher.mjs +15 -5
  35. package/api/search/exportSearchIndex.doc.d.mts +10 -0
  36. package/api/search/exportSearchIndex.doc.mjs +58 -0
  37. package/api/search/rankSearchIndex.doc.d.mts +10 -0
  38. package/api/search/rankSearchIndex.doc.mjs +79 -0
  39. package/api/search/search-index.d.mts +44 -0
  40. package/api/search/search-index.mjs +270 -0
  41. package/api/search/search.type.d.mts +28 -0
  42. package/api/search/search.type.mjs +17 -0
  43. package/api/swizzle/_moduleGraph.d.mts +7 -0
  44. package/api/swizzle/_moduleGraph.mjs +191 -83
  45. package/api/swizzle/copy/copy.mjs +28 -6
  46. package/api/template/skeleton/skeleton.mjs +1 -1
  47. package/api/template/template.mjs +1 -0
  48. package/assets/codemods/transforms/v0.1.0/drop-xds-prefix-imports.mjs +1 -1
  49. package/assets/codemods/transforms/v0.1.0/index.mjs +1 -1
  50. package/assets/discover/official-packages.json +16 -0
  51. package/assets/docs/styling-overview.doc.mjs +3 -3
  52. package/assets/docs/tree/icon-sets.doc.mjs +4 -4
  53. package/assets/docs/tree/render-pages.doc.mjs +3 -3
  54. package/assets/docs/tree/tailwind.doc.mjs +41 -1
  55. package/assets/docs/tree/type-scale.doc.mjs +19 -2
  56. package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
  57. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.doc.mjs +14 -0
  58. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.tsx +56 -0
  59. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.doc.mjs +2 -2
  60. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.tsx +66 -10
  61. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.doc.mjs +14 -0
  62. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.tsx +39 -0
  63. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.doc.mjs +14 -0
  64. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.tsx +83 -0
  65. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.doc.mjs +14 -0
  66. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.tsx +41 -0
  67. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.doc.mjs +14 -0
  68. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.tsx +97 -0
  69. package/assets/templates/pages/table-filter/page.tsx +15 -23
  70. package/assets/templates/pages/table-grouped/page.tsx +30 -30
  71. package/assets/templates/pages/table-inbox/page.tsx +3 -6
  72. package/assets/templates/themes/butter/butterTheme.ts +1 -1
  73. package/assets/templates/themes/gothic/gothicTheme.ts +16 -0
  74. package/assets/templates/themes/matcha/matchaTheme.ts +1 -1
  75. package/assets/templates/themes/neutral/neutralTheme.ts +6 -0
  76. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
  77. package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
  78. package/clients/cli/commands/docs.doc.mjs +5 -1
  79. package/clients/cli/commands/docs.mjs +30 -2
  80. package/clients/cli/commands/experimental/icon.mjs +25 -4
  81. package/clients/cli/commands/experimental-render.doc.mjs +1 -1
  82. package/clients/cli/commands/template.mjs +204 -181
  83. package/clients/cli/lib/resolve-theme.mjs +16 -7
  84. package/foundation/discovery/component-discovery.mjs +1 -1
  85. package/foundation/discovery/hook-discovery.mjs +31 -8
  86. package/foundation/discovery/icon-set-writer.d.mts +21 -5
  87. package/foundation/discovery/icon-set-writer.mjs +114 -13
  88. package/foundation/discovery/template-adapter.mjs +2 -2
  89. package/foundation/doc-compiler/import.d.mts +5 -1
  90. package/foundation/doc-compiler/import.mjs +40 -6
  91. package/foundation/fs/import-url.d.mts +20 -0
  92. package/foundation/fs/import-url.mjs +22 -0
  93. package/foundation/fs/module-loader.d.mts +24 -3
  94. package/foundation/fs/module-loader.mjs +69 -47
  95. package/foundation/render/charts.d.mts +59 -0
  96. package/foundation/render/charts.mjs +216 -0
  97. package/foundation/render/embedded-imports.d.mts +7 -7
  98. package/foundation/render/embedded-imports.mjs +63 -54
  99. package/foundation/render/page-host.d.mts +4 -0
  100. package/foundation/render/page-host.mjs +45 -0
  101. package/foundation/render/page-worker.mjs +350 -57
  102. package/foundation/render/render-page.d.mts +11 -6
  103. package/foundation/render/render-page.mjs +164 -54
  104. package/foundation/render/ts-paths.d.mts +63 -0
  105. package/foundation/render/ts-paths.mjs +138 -0
  106. package/foundation/response/error-codes.doc.mjs +3 -3
  107. package/foundation/response/error-codes.mjs +3 -2
  108. package/foundation/text/levenshtein.d.mts +6 -1
  109. package/foundation/text/levenshtein.mjs +25 -9
  110. package/foundation/text/suggest-order.d.mts +8 -1
  111. package/foundation/text/suggest-order.mjs +72 -6
  112. package/foundation/xle/registry-core.mjs +1 -1
  113. package/package.json +7 -6
@@ -54,7 +54,7 @@ export const doc = {
54
54
  name: 'topic',
55
55
  type: 'string',
56
56
  description:
57
- "Doc topic to load (e.g. 'principles'), or a docs-tree route (e.g. 'cli/api/functions/search'). Omit to list all topics.",
57
+ "Doc topic to load (e.g. 'principles'), a docs-tree route (e.g. 'cli/api/functions/search'), or the name of one node of the docs tree: its own name (e.g. 'tokens-color'), or its route without the prefix its name repeats (e.g. 'tokens/color'), where exactly one node answers to it. Omit to list all topics.",
58
58
  },
59
59
  {
60
60
  name: 'section',
@@ -88,13 +88,13 @@ export const doc = {
88
88
  name: 'options.depth',
89
89
  type: "number | 'all'",
90
90
  description:
91
- "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
+ "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. On the topic list, where each namespace otherwise lists alone, it names the docs below each one, as deep as asked; without it the list is unchanged.",
92
92
  },
93
93
  {
94
94
  name: 'options.detail',
95
95
  type: "'brief' | 'compact' | 'full'",
96
96
  description:
97
- "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
+ "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. The topic list names each doc below a namespace by its identity whatever the detail.",
98
98
  },
99
99
  {
100
100
  name: 'options.cwd',
@@ -107,7 +107,7 @@ export const doc = {
107
107
  {
108
108
  type: 'docs.list',
109
109
  description:
110
- "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}), and meta.notLoaded each package whose docs did not load ({package, message}).",
110
+ "Every reference-doc topic in read order, as DocsListEntry[] ({topic, description, package, replaces?, replacedPackage?}), each readable with docs(topic). meta.namespaces lists the docs tree's top-level namespaces ({topic, description, package}); with depth, each also carries children, the docs below it as a namespace read names them ({topic, description, route, name, package, kind, title, summary, replaces?, replacedPackage?, stability?}), nested the same way to the depth asked for, and childCount where the depth stops on a doc with docs below it. meta.notLoaded names each package whose docs did not load ({package, message}).",
111
111
  },
112
112
  {
113
113
  type: 'docs.detail',
@@ -141,7 +141,7 @@ export const doc = {
141
141
  },
142
142
  {
143
143
  code: 'ERR_UNKNOWN_TOPIC',
144
- when: 'the topic is not a string, or matches no topic and no docs-tree route',
144
+ when: 'the topic is not a string, or matches no topic, no docs-tree route, and no one node of the docs tree by its own name or by its route without the prefix its name repeats; a name more than one node answers to opens none of them, and the suggestions list them',
145
145
  },
146
146
  {
147
147
  code: 'ERR_UNKNOWN_SECTION',
@@ -56,6 +56,27 @@ export type DocsListNamespace = {
56
56
  * the package that owns it
57
57
  */
58
58
  package: string;
59
+ /**
60
+ * the docs below it, present only for
61
+ * a read that passed `depth` and only where the namespace has children
62
+ */
63
+ children?: DocsListChild[] | undefined;
64
+ /**
65
+ * how many docs sit right below it, where a
66
+ * depth read stops here and it has docs below it
67
+ */
68
+ childCount?: number | undefined;
69
+ };
70
+ /**
71
+ * One doc below a namespace on the topic list, as `astryx docs --depth` names
72
+ * it: everything a namespace read gives a child, plus the two fields every
73
+ * list row carries, so one row reads the same way wherever it came from.
74
+ */
75
+ export type DocsListChild = DocsNodeChild & {
76
+ topic: string;
77
+ description: string;
78
+ children?: DocsListChild[];
79
+ childCount?: number;
59
80
  };
60
81
  /**
61
82
  * astryx --json docs <topic> --index
@@ -45,6 +45,17 @@
45
45
  * @property {string} topic its route, the argument that opens it
46
46
  * @property {string} description
47
47
  * @property {string} package the package that owns it
48
+ * @property {DocsListChild[]} [children] the docs below it, present only for
49
+ * a read that passed `depth` and only where the namespace has children
50
+ * @property {number} [childCount] how many docs sit right below it, where a
51
+ * depth read stops here and it has docs below it
52
+ */
53
+
54
+ /**
55
+ * One doc below a namespace on the topic list, as `astryx docs --depth` names
56
+ * it: everything a namespace read gives a child, plus the two fields every
57
+ * list row carries, so one row reads the same way wherever it came from.
58
+ * @typedef {DocsNodeChild & {topic: string, description: string, children?: DocsListChild[], childCount?: number}} DocsListChild
48
59
  */
49
60
 
50
61
  /**
@@ -4,8 +4,12 @@
4
4
  /**
5
5
  * @param {object} [options]
6
6
  * @param {string} [options.cwd]
7
+ * @param {number | 'all'} [options.depth] how many levels of the docs tree to
8
+ * list below each namespace; without it the namespaces list alone, as they
9
+ * always have
7
10
  * @returns {Promise<import('../docs.type.mjs').DocsListResponse>}
8
11
  */
9
- export function list({ cwd }?: {
12
+ export function list({ cwd, depth }?: {
10
13
  cwd?: string | undefined;
14
+ depth?: number | "all" | undefined;
11
15
  }): Promise<import("../docs.type.mjs").DocsListResponse>;
@@ -16,6 +16,7 @@
16
16
 
17
17
  import {loadTopicFile} from '../../../foundation/doc-compiler/read.mjs';
18
18
  import {
19
+ childIdentity,
19
20
  holdsOwnName,
20
21
  linkDocText,
21
22
  loadDocsCatalog,
@@ -25,9 +26,12 @@ import {
25
26
  /**
26
27
  * @param {object} [options]
27
28
  * @param {string} [options.cwd]
29
+ * @param {number | 'all'} [options.depth] how many levels of the docs tree to
30
+ * list below each namespace; without it the namespaces list alone, as they
31
+ * always have
28
32
  * @returns {Promise<import('../docs.type.mjs').DocsListResponse>}
29
33
  */
30
- export async function list({cwd} = {}) {
34
+ export async function list({cwd, depth} = {}) {
31
35
  const catalog = await loadDocsCatalog(cwd);
32
36
  const tree = await projectTree(catalog);
33
37
  /** @type {Array<import('../docs.type.mjs').DocsListEntry>} */
@@ -64,11 +68,11 @@ export async function list({cwd} = {}) {
64
68
  // The docs tree's top-level namespaces, the CLI's and each integration's,
65
69
  // each the way into a whole branch (spec:AST-046 FR7). They go in `meta`,
66
70
  // so `data` stays the topic list 0.6 returned: every entry reads as a topic.
67
- const namespaces = tree.roots().map(root => ({
68
- topic: root.route,
69
- description: root.summary,
70
- package: root.provider,
71
- }));
71
+ // With `depth`, each one also carries the branch below it, so one read
72
+ // learns every route: without it a reader knows only that the namespace is
73
+ // there, and the children it must name are invisible until it opens each one.
74
+ const levels = depthLevels(depth);
75
+ const namespaces = tree.roots().map(root => branch(tree, root, levels));
72
76
  /** @type {NonNullable<import('../docs.type.mjs').DocsListResponse['meta']>} */
73
77
  const meta = {};
74
78
  if (namespaces.length > 0) meta.namespaces = namespaces;
@@ -79,3 +83,65 @@ export async function list({cwd} = {}) {
79
83
  ? {type: 'docs.list', data: entries}
80
84
  : {type: 'docs.list', data: entries, meta};
81
85
  }
86
+
87
+ /**
88
+ * How many levels below each namespace the list carries: none without
89
+ * `depth`, every level for `'all'`. `docs <namespace> --depth` reads the same
90
+ * way, so one flag means one thing everywhere.
91
+ * @param {number | 'all'} [depth]
92
+ * @returns {number | null} null for a list read with no depth, which carries
93
+ * the namespaces alone
94
+ */
95
+ function depthLevels(depth) {
96
+ if (depth == null) return null;
97
+ return depth === 'all' ? Infinity : depth;
98
+ }
99
+
100
+ /**
101
+ * One namespace of the list, with the branch below it to `levels`. A child
102
+ * reads exactly as a namespace read gives it (`childIdentity`): the route
103
+ * that opens it, and the package that owns it — the integration's, for a
104
+ * guide an integration replaced, with the package whose route it took beside
105
+ * it. Every line of the list is then an argument a reader can pass straight
106
+ * back to `astryx docs`, attributed the way the read attributes it. Where the
107
+ * depth stops on a doc with docs below it, the row says how many, as a
108
+ * namespace read's child does; `levels` of null is a read with no depth,
109
+ * which says nothing about what is below.
110
+ * @param {import('../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
111
+ * @param {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} node
112
+ * @param {number | null} levels
113
+ * @returns {import('../docs.type.mjs').DocsListNamespace}
114
+ */
115
+ function branch(tree, node, levels) {
116
+ /** @type {import('../docs.type.mjs').DocsListNamespace} */
117
+ const listed = {
118
+ topic: node.route,
119
+ description: node.summary,
120
+ package: node.provider,
121
+ };
122
+ if (levels == null) return listed;
123
+ const below = node.slots.flatMap(slot => slot.children);
124
+ if (levels <= 0) {
125
+ if (below.length > 0) listed.childCount = below.length;
126
+ return listed;
127
+ }
128
+ const children = below
129
+ .map(route => tree.get(route))
130
+ .filter(child => child != null)
131
+ .map(child => {
132
+ const node = /** @type {import('../../../foundation/doc-compiler/tree.mjs').TreeNode} */ (
133
+ child
134
+ );
135
+ const {topic: _route, ...rest} = branch(tree, node, levels - 1);
136
+ const identity = childIdentity(tree, node);
137
+ return /** @type {import('../docs.type.mjs').DocsListChild} */ ({
138
+ ...identity,
139
+ topic: identity.route,
140
+ description: identity.summary,
141
+ ...(rest.children ? {children: rest.children} : {}),
142
+ ...(rest.childCount ? {childCount: rest.childCount} : {}),
143
+ });
144
+ });
145
+ if (children.length > 0) listed.children = children;
146
+ return listed;
147
+ }
@@ -16,13 +16,14 @@
16
16
  */
17
17
 
18
18
  import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
19
- import {isExperimentalTreeNode} from '../../../foundation/doc-compiler/tree.mjs';
20
19
  import {
20
+ childIdentity,
21
21
  compileTopic,
22
22
  guideEntry,
23
23
  nodeContent,
24
24
  placeLinks,
25
25
  resolveDocsArgument,
26
+ stabilityOf,
26
27
  unknownTopicError,
27
28
  } from '../_adapter.mjs';
28
29
 
@@ -87,45 +88,6 @@ export async function nodeView(catalog, tree, node, read) {
87
88
  return view;
88
89
  }
89
90
 
90
- /**
91
- * `stability: 'experimental'` for a node whose doc is marked experimental, or
92
- * that sits under an experimental namespace (spec:AST-017 FR27), the way help
93
- * marks an experimental command; nothing for a stable one, so stable entries
94
- * read as they always have.
95
- * @param {DocsTree} tree
96
- * @param {TreeNode} node
97
- * @returns {{stability?: 'experimental'}}
98
- */
99
- function stabilityOf(tree, node) {
100
- return isExperimentalTreeNode(tree, node) ? {stability: 'experimental'} : {};
101
- }
102
-
103
- /**
104
- * The fields every child carries: what it is, and the route that opens it.
105
- * @param {DocsTree} tree
106
- * @param {TreeNode} child
107
- * @returns {import('../docs.type.mjs').DocsNodeChild}
108
- */
109
- function childIdentity(tree, child) {
110
- return {
111
- route: child.route,
112
- name: child.route.slice(child.route.lastIndexOf('/') + 1),
113
- package: child.guideOverlay?.replacement?.package ?? child.provider,
114
- // A guide an integration's doc took the place of names whose it was.
115
- ...(child.guideOverlay?.replacement
116
- ? {
117
- replaces: child.route,
118
- replacedPackage:
119
- child.guideOverlay.replacedPackage ?? child.provider,
120
- }
121
- : {}),
122
- kind: child.kind,
123
- title: child.title,
124
- summary: child.summary,
125
- ...stabilityOf(tree, child),
126
- };
127
- }
128
-
129
91
  /**
130
92
  * @param {TreeNode['slots']} slots
131
93
  * @returns {number}
@@ -196,14 +196,14 @@ export function checkCliCommand(ctx: DoctorContext): DoctorCheck;
196
196
  * @property {{cli: string, core: string | null, copy: string}} answeredBy
197
197
  * @property {string | null} latest the newest release known, or null
198
198
  * @property {Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState}>} [agentText]
199
- * each file of the computer-level agent text against this release's rendering
199
+ * each file of the computer-level agent text against this release's rendering
200
200
  * @property {import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings} [agentTextSettings]
201
201
  * the person's choices about the computer-level agent text
202
202
  * @property {string | null} [agentTextCommand] the command the skill file
203
203
  * tells agents to run, or null
204
204
  * @property {string | null} [agentTextInstall] the install step the skill
205
205
  * file records for when that command is not found, or null
206
- * @property {string} [cwd] the folder doctor runs in, for the printed fix
206
+ * @property {string} [cwd] the folder doctor runs in, for the printed fix
207
207
  * @property {import('../../foundation/release/notices.mjs').GlobalBehind | null} [globalBehind]
208
208
  * the CLI installed for the computer, when it is older than the newest
209
209
  * release (outside a project)
@@ -215,7 +215,7 @@ export function checkCliCommand(ctx: DoctorContext): DoctorCheck;
215
215
  * the newest update notice that did not print, and why (diagnostic only)
216
216
  * @property {{pid: number | null, host: string | null, since: number} | null} [stateLock]
217
217
  * who holds the state file's lock now (diagnostic only)
218
- * @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null, runner?: boolean}>} [searchPathCommands]
218
+ * @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null, runner?: boolean}>} [searchPathCommands]
219
219
  * every `astryx` on the search path, with the command that upgrades it
220
220
  * the `astryx` commands on the search path, in order
221
221
  * @property {import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]} [computerIntegrations]
@@ -281,7 +281,7 @@ export function checkComputerIntegrations(ctx: ComputerContext): DoctorCheck;
281
281
  * fix points at the project's folder
282
282
  * @returns {DoctorCheck}
283
283
  */
284
- export function checkComputerIntegrationsAvailable({ installed, candidates, install, elsewhere }: {
284
+ export function checkComputerIntegrationsAvailable({ installed, candidates, install, elsewhere, }: {
285
285
  installed: Set<string>;
286
286
  candidates: import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[];
287
287
  install: ((name: string) => string) | null;