@g3nomaly/analyze 0.0.0-stage → 0.1.0

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 (130) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +71 -2
  3. package/dist/THIRD_PARTY_LICENSES.txt +1904 -0
  4. package/dist/api/bundle-builder.d.ts +75 -0
  5. package/dist/api/bundle-cache.d.ts +70 -0
  6. package/dist/api/bundle-loader.d.ts +58 -0
  7. package/dist/api/create-docs.d.ts +72 -0
  8. package/dist/api/embedding.d.ts +32 -0
  9. package/dist/api/errors.d.ts +28 -0
  10. package/dist/api/list.d.ts +106 -0
  11. package/dist/api/options.d.ts +78 -0
  12. package/dist/api/refs.d.ts +133 -0
  13. package/dist/api/scan.d.ts +44 -0
  14. package/dist/api/search.d.ts +126 -0
  15. package/dist/api/services.d.ts +7 -0
  16. package/dist/api/show.d.ts +104 -0
  17. package/dist/api/site-reader.d.ts +11 -0
  18. package/dist/api/site-writer.d.ts +20 -0
  19. package/dist/api/source.d.ts +46 -0
  20. package/dist/api/target.d.ts +10 -0
  21. package/dist/api/template.d.ts +5 -0
  22. package/dist/assets/tree-sitter-c-sharp.wasm +0 -0
  23. package/dist/assets/tree-sitter-c.wasm +0 -0
  24. package/dist/assets/tree-sitter-cpp.wasm +0 -0
  25. package/dist/assets/tree-sitter-go.wasm +0 -0
  26. package/dist/assets/tree-sitter-java.wasm +0 -0
  27. package/dist/assets/tree-sitter-javascript.wasm +0 -0
  28. package/dist/assets/tree-sitter-kotlin.wasm +0 -0
  29. package/dist/assets/tree-sitter-php.wasm +0 -0
  30. package/dist/assets/tree-sitter-python.wasm +0 -0
  31. package/dist/assets/tree-sitter-ruby.wasm +0 -0
  32. package/dist/assets/tree-sitter-rust.wasm +0 -0
  33. package/dist/assets/tree-sitter-scala.wasm +0 -0
  34. package/dist/assets/tree-sitter-tsx.wasm +0 -0
  35. package/dist/assets/tree-sitter-typescript.wasm +0 -0
  36. package/dist/assets/vectors.bin +0 -0
  37. package/dist/assets/vocab.txt +33731 -0
  38. package/dist/cli.js +8885 -0
  39. package/dist/embeddings/abbreviations.d.ts +7 -0
  40. package/dist/embeddings/index-builder.d.ts +10 -0
  41. package/dist/embeddings/index.d.ts +10 -0
  42. package/dist/embeddings/model.d.ts +113 -0
  43. package/dist/embeddings/searcher.d.ts +67 -0
  44. package/dist/embeddings/vectors.d.ts +75 -0
  45. package/dist/embeddings/words.d.ts +42 -0
  46. package/dist/index.d.ts +9 -0
  47. package/dist/index.js +8329 -0
  48. package/dist/model/index.d.ts +560 -0
  49. package/dist/model/registry.d.ts +494 -0
  50. package/dist/query/graph.d.ts +66 -0
  51. package/dist/query/index.d.ts +4 -0
  52. package/dist/query/name-search.d.ts +47 -0
  53. package/dist/query/semantic.d.ts +30 -0
  54. package/dist/query/text.d.ts +22 -0
  55. package/dist/retrieval/describe.d.ts +26 -0
  56. package/dist/retrieval/filter.d.ts +17 -0
  57. package/dist/retrieval/index.d.ts +7 -0
  58. package/dist/retrieval/markdown.d.ts +16 -0
  59. package/dist/retrieval/report.d.ts +214 -0
  60. package/dist/retrieval/resolve.d.ts +27 -0
  61. package/dist/retrieval/retriever.d.ts +94 -0
  62. package/dist/retrieval/summary.d.ts +24 -0
  63. package/dist/scanner/code/doc/clean.d.ts +10 -0
  64. package/dist/scanner/code/doc/index.d.ts +6 -0
  65. package/dist/scanner/code/doc/markdown.d.ts +3 -0
  66. package/dist/scanner/code/doc/python.d.ts +3 -0
  67. package/dist/scanner/code/doc/tagged.d.ts +10 -0
  68. package/dist/scanner/code/doc/types.d.ts +22 -0
  69. package/dist/scanner/code/doc/xml.d.ts +3 -0
  70. package/dist/scanner/code/example.d.ts +36 -0
  71. package/dist/scanner/code/extract.d.ts +78 -0
  72. package/dist/scanner/code/grammar.d.ts +29 -0
  73. package/dist/scanner/code/language.d.ts +149 -0
  74. package/dist/scanner/code/languages/c-family.d.ts +5 -0
  75. package/dist/scanner/code/languages/csharp.d.ts +3 -0
  76. package/dist/scanner/code/languages/ecmascript.d.ts +7 -0
  77. package/dist/scanner/code/languages/go.d.ts +3 -0
  78. package/dist/scanner/code/languages/index.d.ts +19 -0
  79. package/dist/scanner/code/languages/java.d.ts +3 -0
  80. package/dist/scanner/code/languages/kotlin.d.ts +3 -0
  81. package/dist/scanner/code/languages/php.d.ts +3 -0
  82. package/dist/scanner/code/languages/python.d.ts +3 -0
  83. package/dist/scanner/code/languages/ruby.d.ts +3 -0
  84. package/dist/scanner/code/languages/rust.d.ts +3 -0
  85. package/dist/scanner/code/languages/scala.d.ts +3 -0
  86. package/dist/scanner/code/languages/shared.d.ts +17 -0
  87. package/dist/scanner/code/planner.d.ts +71 -0
  88. package/dist/scanner/code/symbols.d.ts +68 -0
  89. package/dist/scanner/code/types.d.ts +93 -0
  90. package/dist/scanner/content.d.ts +38 -0
  91. package/dist/scanner/decisions/parse.d.ts +28 -0
  92. package/dist/scanner/decisions/planner.d.ts +30 -0
  93. package/dist/scanner/docs.d.ts +52 -0
  94. package/dist/scanner/files.d.ts +60 -0
  95. package/dist/scanner/glossary/parse.d.ts +30 -0
  96. package/dist/scanner/glossary/planner.d.ts +42 -0
  97. package/dist/scanner/glossary/terms.d.ts +86 -0
  98. package/dist/scanner/graph/builder.d.ts +55 -0
  99. package/dist/scanner/highlight.d.ts +31 -0
  100. package/dist/scanner/index.d.ts +40 -0
  101. package/dist/scanner/markdown/frontmatter.d.ts +9 -0
  102. package/dist/scanner/markdown/links.d.ts +50 -0
  103. package/dist/scanner/markdown/outline.d.ts +27 -0
  104. package/dist/scanner/markdown/renderer.d.ts +44 -0
  105. package/dist/scanner/openapi/planner.d.ts +84 -0
  106. package/dist/scanner/reporter.d.ts +7 -0
  107. package/dist/scanner/scanner.d.ts +52 -0
  108. package/dist/scanner/schema/definitions.d.ts +69 -0
  109. package/dist/scanner/schema/describe.d.ts +79 -0
  110. package/dist/scanner/schema/planner.d.ts +46 -0
  111. package/dist/scanner/schema/registry.d.ts +61 -0
  112. package/dist/scanner/skills/classify.d.ts +20 -0
  113. package/dist/scanner/skills/layout.d.ts +28 -0
  114. package/dist/scanner/skills/planner.d.ts +46 -0
  115. package/dist/scanner/specs.d.ts +50 -0
  116. package/dist/scanner/sql/catalog.d.ts +84 -0
  117. package/dist/scanner/sql/cursor.d.ts +107 -0
  118. package/dist/scanner/sql/database.d.ts +48 -0
  119. package/dist/scanner/sql/parse.d.ts +87 -0
  120. package/dist/scanner/sql/planner.d.ts +65 -0
  121. package/dist/scanner/sql/query.d.ts +60 -0
  122. package/dist/scanner/sql/registry.d.ts +49 -0
  123. package/dist/scanner/sql/source.d.ts +9 -0
  124. package/dist/scanner/sql/statements.d.ts +36 -0
  125. package/dist/scanner/sql/tokens.d.ts +38 -0
  126. package/dist/scanner/tasks/layout.d.ts +40 -0
  127. package/dist/scanner/tasks/planner.d.ts +75 -0
  128. package/dist/scanner/tasks/schema.d.ts +88 -0
  129. package/dist/scanner/text.d.ts +14 -0
  130. package/package.json +104 -4
@@ -0,0 +1,494 @@
1
+ import * as z from 'zod/mini';
2
+ /**
3
+ * The role a node kind plays in the site.
4
+ * - `section`: a top-level group.
5
+ * - `folder`: a directory.
6
+ * - `file`: a file with a page of its own.
7
+ * - `source`: a source file, a page whose symbols are its entries.
8
+ * - `symbol`: a declaration in code, shown as an entry.
9
+ * - `entry`: any other block on the page of its file, with an anchor of its own.
10
+ * - `member`: a parameter or a field, a row of its entry.
11
+ */
12
+ export declare const NodeGroupSchema: z.ZodMiniEnum<{
13
+ entry: "entry";
14
+ file: "file";
15
+ folder: "folder";
16
+ member: "member";
17
+ section: "section";
18
+ source: "source";
19
+ symbol: "symbol";
20
+ }>;
21
+ /** One of the roles of {@link NodeGroupSchema}. */
22
+ export type NodeGroup = z.infer<typeof NodeGroupSchema>;
23
+ /** What the registry states about one node kind. */
24
+ export declare const NodeKindSpecSchema: z.ZodMiniObject<{
25
+ group: z.ZodMiniEnum<{
26
+ entry: "entry";
27
+ file: "file";
28
+ folder: "folder";
29
+ member: "member";
30
+ section: "section";
31
+ source: "source";
32
+ symbol: "symbol";
33
+ }>;
34
+ label: z.ZodMiniString<string>;
35
+ description: z.ZodMiniString<string>;
36
+ letter: z.ZodMiniOptional<z.ZodMiniString<string>>;
37
+ prose: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
38
+ typeLike: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
39
+ container: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
40
+ described: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
41
+ }, z.core.$strict>;
42
+ /** The parsed spec of one node kind, with defaults filled in. */
43
+ export type NodeKindSpec = z.infer<typeof NodeKindSpecSchema>;
44
+ /** What the registry states about one top-level section. */
45
+ export declare const SectionSpecSchema: z.ZodMiniObject<{
46
+ label: z.ZodMiniString<string>;
47
+ description: z.ZodMiniString<string>;
48
+ }, z.core.$strict>;
49
+ /** The parsed spec of one section. */
50
+ export type SectionSpec = z.infer<typeof SectionSpecSchema>;
51
+ /** What the registry states about a family of relation kinds that the graph draws in one color. */
52
+ export declare const RelationFamilySpecSchema: z.ZodMiniObject<{
53
+ label: z.ZodMiniString<string>;
54
+ description: z.ZodMiniString<string>;
55
+ colorToken: z.ZodMiniString<string>;
56
+ }, z.core.$strict>;
57
+ /** The parsed spec of one relation family. */
58
+ export type RelationFamilySpec = z.infer<typeof RelationFamilySpecSchema>;
59
+ /** What the registry states about one relation kind: what it means, which way it points and how it is drawn. */
60
+ export declare const RelationKindSpecSchema: z.ZodMiniObject<{
61
+ label: z.ZodMiniString<string>;
62
+ description: z.ZodMiniString<string>;
63
+ forward: z.ZodMiniString<string>;
64
+ backward: z.ZodMiniString<string>;
65
+ from: z.ZodMiniString<string>;
66
+ to: z.ZodMiniString<string>;
67
+ family: z.ZodMiniString<string>;
68
+ dashed: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
69
+ }, z.core.$strict>;
70
+ /** The parsed spec of one relation kind, with defaults filled in. */
71
+ export type RelationKindSpec = z.infer<typeof RelationKindSpecSchema>;
72
+ /** The top-level sections, in display order. */
73
+ export declare const SECTION_REGISTRY: {
74
+ readonly skills: {
75
+ readonly label: 'Skills';
76
+ readonly description: 'Every `SKILL.md` and the files beside it.';
77
+ };
78
+ readonly docs: {
79
+ readonly label: 'Docs';
80
+ readonly description: 'Markdown, JSON, OpenAPI documents and JSON Schemas.';
81
+ };
82
+ readonly code: {
83
+ readonly label: 'Code';
84
+ readonly description: 'Source files with their classes and functions.';
85
+ };
86
+ readonly database: {
87
+ readonly label: 'Database';
88
+ readonly description: 'SQL files, as schemas with their tables and as query catalogs.';
89
+ };
90
+ readonly tasks: {
91
+ readonly label: 'Tasks';
92
+ readonly description: 'Plans, their phases and their tasks, as task-manager keeps them.';
93
+ };
94
+ };
95
+ /** Every node kind, in the order the site lists kinds. */
96
+ export declare const NODE_KIND_REGISTRY: {
97
+ readonly section: {
98
+ readonly group: 'section';
99
+ readonly label: 'section';
100
+ readonly description: 'A top-level group of the site.';
101
+ };
102
+ readonly folder: {
103
+ readonly group: 'folder';
104
+ readonly label: 'folder';
105
+ readonly description: 'A directory of the repository.';
106
+ };
107
+ readonly skill: {
108
+ readonly group: 'file';
109
+ readonly label: 'skill';
110
+ readonly description: 'A `SKILL.md`. The other files of its directory belong to it.';
111
+ };
112
+ readonly reference: {
113
+ readonly group: 'file';
114
+ readonly label: 'reference';
115
+ readonly description: 'A markdown file of a skill.';
116
+ };
117
+ readonly agent: {
118
+ readonly group: 'file';
119
+ readonly label: 'agent';
120
+ readonly description: 'A file in the `agents/` directory of a skill.';
121
+ };
122
+ readonly hook: {
123
+ readonly group: 'file';
124
+ readonly label: 'hook';
125
+ readonly description: 'A file in the `hooks/` directory of a skill.';
126
+ };
127
+ readonly schema: {
128
+ readonly group: 'file';
129
+ readonly label: 'schema';
130
+ readonly description: 'A JSON Schema, or a schema file of a skill.';
131
+ };
132
+ readonly asset: {
133
+ readonly group: 'file';
134
+ readonly label: 'file';
135
+ readonly description: 'Any other file of a skill.';
136
+ };
137
+ readonly document: {
138
+ readonly group: 'file';
139
+ readonly label: 'document';
140
+ readonly description: 'A markdown file.';
141
+ };
142
+ readonly json: {
143
+ readonly group: 'file';
144
+ readonly label: 'JSON';
145
+ readonly description: 'A JSON file.';
146
+ };
147
+ readonly glossary: {
148
+ readonly group: 'file';
149
+ readonly label: 'glossary';
150
+ readonly description: 'A `glossary.md`. Its terms are its entries.';
151
+ };
152
+ readonly decisions: {
153
+ readonly group: 'file';
154
+ readonly label: 'decisions';
155
+ readonly description: 'A `decisions.md`. Its decisions are its entries.';
156
+ };
157
+ readonly api: {
158
+ readonly group: 'file';
159
+ readonly label: 'API';
160
+ readonly description: 'An OpenAPI document. Its operations and definitions are its entries.';
161
+ };
162
+ readonly database: {
163
+ readonly group: 'file';
164
+ readonly label: 'database';
165
+ readonly description: 'A `.sql` file that creates tables. Its tables are its entries.';
166
+ };
167
+ readonly catalog: {
168
+ readonly group: 'file';
169
+ readonly label: 'catalog';
170
+ readonly description: 'A directory of `.sql` files that create no table. Its queries are its entries.';
171
+ };
172
+ readonly plan: {
173
+ readonly group: 'file';
174
+ readonly label: 'plan';
175
+ readonly description: 'A plan of the task tree. Its phases are its children.';
176
+ };
177
+ readonly phase: {
178
+ readonly group: 'file';
179
+ readonly label: 'phase';
180
+ readonly description: 'A phase of a plan. Its tasks are its entries.';
181
+ };
182
+ readonly source: {
183
+ readonly group: 'source';
184
+ readonly label: 'code';
185
+ readonly description: 'A source file. Its classes and functions are its entries.';
186
+ };
187
+ readonly namespace: {
188
+ readonly group: 'symbol';
189
+ readonly label: 'namespace';
190
+ readonly description: 'A namespace or a module.';
191
+ readonly letter: 'N';
192
+ readonly container: true;
193
+ };
194
+ readonly class: {
195
+ readonly group: 'symbol';
196
+ readonly label: 'class';
197
+ readonly description: 'A class.';
198
+ readonly letter: 'C';
199
+ readonly typeLike: true;
200
+ readonly container: true;
201
+ };
202
+ readonly interface: {
203
+ readonly group: 'symbol';
204
+ readonly label: 'interface';
205
+ readonly description: 'An interface or a protocol.';
206
+ readonly letter: 'I';
207
+ readonly typeLike: true;
208
+ readonly container: true;
209
+ };
210
+ readonly struct: {
211
+ readonly group: 'symbol';
212
+ readonly label: 'struct';
213
+ readonly description: 'A struct or a record.';
214
+ readonly letter: 'S';
215
+ readonly typeLike: true;
216
+ readonly container: true;
217
+ };
218
+ readonly enum: {
219
+ readonly group: 'symbol';
220
+ readonly label: 'enum';
221
+ readonly description: 'An enumeration.';
222
+ readonly letter: 'E';
223
+ readonly typeLike: true;
224
+ readonly container: true;
225
+ };
226
+ readonly trait: {
227
+ readonly group: 'symbol';
228
+ readonly label: 'trait';
229
+ readonly description: 'A trait or a mixin.';
230
+ readonly letter: 'T';
231
+ readonly typeLike: true;
232
+ readonly container: true;
233
+ };
234
+ readonly type: {
235
+ readonly group: 'symbol';
236
+ readonly label: 'type';
237
+ readonly description: 'A type alias.';
238
+ readonly letter: 'T';
239
+ readonly typeLike: true;
240
+ readonly container: true;
241
+ };
242
+ readonly function: {
243
+ readonly group: 'symbol';
244
+ readonly label: 'function';
245
+ readonly description: 'A function.';
246
+ readonly letter: 'F';
247
+ };
248
+ readonly method: {
249
+ readonly group: 'symbol';
250
+ readonly label: 'method';
251
+ readonly description: 'A method of a type.';
252
+ readonly letter: 'M';
253
+ };
254
+ readonly term: {
255
+ readonly group: 'entry';
256
+ readonly label: 'term';
257
+ readonly description: 'A word of the project and what it means.';
258
+ readonly prose: true;
259
+ };
260
+ readonly decision: {
261
+ readonly group: 'entry';
262
+ readonly label: 'decision';
263
+ readonly description: 'A choice that is costly to undo, with its reason.';
264
+ readonly prose: true;
265
+ };
266
+ readonly operation: {
267
+ readonly group: 'entry';
268
+ readonly label: 'operation';
269
+ readonly description: 'A method on a path of an API.';
270
+ readonly described: true;
271
+ };
272
+ readonly definition: {
273
+ readonly group: 'entry';
274
+ readonly label: 'definition';
275
+ readonly description: 'A named JSON Schema.';
276
+ readonly described: true;
277
+ };
278
+ readonly table: {
279
+ readonly group: 'entry';
280
+ readonly label: 'table';
281
+ readonly description: 'A table of a SQL schema.';
282
+ readonly described: true;
283
+ };
284
+ readonly query: {
285
+ readonly group: 'entry';
286
+ readonly label: 'query';
287
+ readonly description: 'An entry of a SQL query catalog.';
288
+ readonly described: true;
289
+ };
290
+ readonly task: {
291
+ readonly group: 'entry';
292
+ readonly label: 'task';
293
+ readonly description: 'One unit of work of a phase, with its status.';
294
+ readonly prose: true;
295
+ };
296
+ readonly parameter: {
297
+ readonly group: 'member';
298
+ readonly label: 'parameter';
299
+ readonly description: 'A parameter of a function, an operation or a query.';
300
+ };
301
+ readonly field: {
302
+ readonly group: 'member';
303
+ readonly label: 'field';
304
+ readonly description: 'A field of a type, a property, a column or a result column.';
305
+ };
306
+ };
307
+ /** The relation families, in legend order. */
308
+ export declare const RELATION_FAMILY_REGISTRY: {
309
+ readonly typing: {
310
+ readonly label: 'typing';
311
+ readonly description: 'What a declaration is made of.';
312
+ readonly colorToken: '--edge-typing';
313
+ };
314
+ readonly result: {
315
+ readonly label: 'result';
316
+ readonly description: 'What a call gives back.';
317
+ readonly colorToken: '--edge-result';
318
+ };
319
+ readonly prose: {
320
+ readonly label: 'prose';
321
+ readonly description: 'What a text points at.';
322
+ readonly colorToken: '--edge-prose';
323
+ };
324
+ readonly term: {
325
+ readonly label: 'term';
326
+ readonly description: 'A text that uses a glossary term.';
327
+ readonly colorToken: '--edge-term';
328
+ };
329
+ readonly key: {
330
+ readonly label: 'key';
331
+ readonly description: 'A foreign key between two tables.';
332
+ readonly colorToken: '--edge-key';
333
+ };
334
+ readonly query: {
335
+ readonly label: 'query';
336
+ readonly description: 'A table a query reads or writes.';
337
+ readonly colorToken: '--edge-query';
338
+ };
339
+ readonly task: {
340
+ readonly label: 'task';
341
+ readonly description: 'What a task names, and what it waits for.';
342
+ readonly colorToken: '--edge-task';
343
+ };
344
+ };
345
+ /** Every relation kind other than `parent`, in the order the site lists them. */
346
+ export declare const RELATION_KIND_REGISTRY: {
347
+ readonly type: {
348
+ readonly label: 'type';
349
+ readonly description: 'A parameter or field has that type, or the request body of an operation has that schema.';
350
+ readonly forward: 'has type';
351
+ readonly backward: 'is the type of';
352
+ readonly from: 'parameter, field, property or operation';
353
+ readonly to: 'type or definition';
354
+ readonly family: 'typing';
355
+ };
356
+ readonly returns: {
357
+ readonly label: 'returns';
358
+ readonly description: 'A function returns that type, or an operation answers with that schema.';
359
+ readonly forward: 'returns';
360
+ readonly backward: 'is returned by';
361
+ readonly from: 'function, method or operation';
362
+ readonly to: 'type or definition';
363
+ readonly family: 'result';
364
+ };
365
+ readonly throws: {
366
+ readonly label: 'throws';
367
+ readonly description: 'A function throws that type, or an operation answers an error with that schema.';
368
+ readonly forward: 'throws';
369
+ readonly backward: 'is thrown by';
370
+ readonly from: 'function, method or operation';
371
+ readonly to: 'type or definition';
372
+ readonly family: 'result';
373
+ readonly dashed: true;
374
+ };
375
+ readonly extends: {
376
+ readonly label: 'extends';
377
+ readonly description: 'A type extends, implements or is composed of that type.';
378
+ readonly forward: 'extends';
379
+ readonly backward: 'is extended by';
380
+ readonly from: 'type or definition';
381
+ readonly to: 'type or definition';
382
+ readonly family: 'typing';
383
+ readonly dashed: true;
384
+ };
385
+ readonly mentions: {
386
+ readonly label: 'mentions';
387
+ readonly description: 'A page or a description links to that node.';
388
+ readonly forward: 'mentions';
389
+ readonly backward: 'is mentioned by';
390
+ readonly from: 'page or entry';
391
+ readonly to: 'any node';
392
+ readonly family: 'prose';
393
+ };
394
+ readonly uses: {
395
+ readonly label: 'uses';
396
+ readonly description: 'A page, a description or a decision uses that glossary term.';
397
+ readonly forward: 'uses';
398
+ readonly backward: 'is used by';
399
+ readonly from: 'page, entry, parameter or field';
400
+ readonly to: 'term';
401
+ readonly family: 'term';
402
+ };
403
+ readonly affects: {
404
+ readonly label: 'affects';
405
+ readonly description: 'A decision is about that node.';
406
+ readonly forward: 'affects';
407
+ readonly backward: 'is affected by';
408
+ readonly from: 'decision';
409
+ readonly to: 'any node';
410
+ readonly family: 'prose';
411
+ readonly dashed: true;
412
+ };
413
+ readonly references: {
414
+ readonly label: 'references';
415
+ readonly description: 'A table has a foreign key to that table.';
416
+ readonly forward: 'references';
417
+ readonly backward: 'is referenced by';
418
+ readonly from: 'table';
419
+ readonly to: 'table';
420
+ readonly family: 'key';
421
+ };
422
+ readonly reads: {
423
+ readonly label: 'reads';
424
+ readonly description: 'A query selects from that table.';
425
+ readonly forward: 'reads';
426
+ readonly backward: 'is read by';
427
+ readonly from: 'query';
428
+ readonly to: 'table';
429
+ readonly family: 'query';
430
+ };
431
+ readonly writes: {
432
+ readonly label: 'writes';
433
+ readonly description: 'A statement inserts into, updates or deletes from that table.';
434
+ readonly forward: 'writes';
435
+ readonly backward: 'is written by';
436
+ readonly from: 'query';
437
+ readonly to: 'table';
438
+ readonly family: 'query';
439
+ readonly dashed: true;
440
+ };
441
+ readonly names: {
442
+ readonly label: 'names';
443
+ readonly description: 'A plan, a phase or a task links to that node or names it in inline code.';
444
+ readonly forward: 'names';
445
+ readonly backward: 'is named by';
446
+ readonly from: 'plan, phase or task';
447
+ readonly to: 'any node';
448
+ readonly family: 'task';
449
+ };
450
+ readonly depends: {
451
+ readonly label: 'depends';
452
+ readonly description: 'A plan, a phase or a task waits for that one to be completed.';
453
+ readonly forward: 'depends on';
454
+ readonly backward: 'is depended on by';
455
+ readonly from: 'plan, phase or task';
456
+ readonly to: 'plan, phase or task';
457
+ readonly family: 'task';
458
+ readonly dashed: true;
459
+ };
460
+ };
461
+ /** Slug of a top-level section, such as `code`. */
462
+ export type Section = keyof typeof SECTION_REGISTRY;
463
+ /** Kind of a node, such as `class` or `table`. */
464
+ export type NodeKind = keyof typeof NODE_KIND_REGISTRY;
465
+ /** Name of a relation family, such as `typing`. */
466
+ export type RelationFamily = keyof typeof RELATION_FAMILY_REGISTRY;
467
+ /** Kind of an edge: any relation kind other than `parent`. */
468
+ export type EdgeKind = keyof typeof RELATION_KIND_REGISTRY;
469
+ /** The node kinds whose group is one of `G`. */
470
+ export type KindsIn<G extends NodeGroup> = {
471
+ [K in NodeKind]: (typeof NODE_KIND_REGISTRY)[K]['group'] extends G ? K : never;
472
+ }[NodeKind];
473
+ /** Every node kind with its parsed spec. */
474
+ export declare const NODE_KINDS: Readonly<Record<NodeKind, NodeKindSpec>>;
475
+ /** Every section with its parsed spec. */
476
+ export declare const SECTION_SPECS: Readonly<Record<Section, SectionSpec>>;
477
+ /** Every relation family with its parsed spec. */
478
+ export declare const RELATION_FAMILIES: Readonly<Record<RelationFamily, RelationFamilySpec>>;
479
+ /** Every relation kind with its parsed spec. */
480
+ export declare const RELATION_KINDS: Readonly<Record<EdgeKind, RelationKindSpec & {
481
+ family: RelationFamily;
482
+ }>>;
483
+ /** The sections, in display order. */
484
+ export declare const SECTIONS: readonly Section[];
485
+ /** Every node kind, in registry order. */
486
+ export declare const ALL_NODE_KINDS: readonly NodeKind[];
487
+ /** Every relation kind, in registry order. */
488
+ export declare const EDGE_KINDS: readonly EdgeKind[];
489
+ /** Every relation family, in legend order. */
490
+ export declare const RELATION_FAMILY_NAMES: readonly RelationFamily[];
491
+ /** Lists the node kinds whose group is one of `groups`, in registry order. */
492
+ export declare function kindsIn<G extends NodeGroup>(...groups: readonly G[]): readonly KindsIn<G>[];
493
+ /** Lists the node kinds for which a flag of the registry is set. */
494
+ export declare function kindsWith(flag: 'typeLike' | 'container' | 'described'): ReadonlySet<NodeKind>;
@@ -0,0 +1,66 @@
1
+ import { type BundleMeta, type DocsBundle, type Edge, type GraphNode, type NodeKind, type NodeRef, type Route, type Section, type SemanticIndex } from '../model';
2
+ /** Tells whether a kind is a row of its entry (`parameter` or `field`) rather than a page or entry of its own. */
3
+ export declare function isDeclarationKind(kind: NodeKind): kind is 'parameter' | 'field';
4
+ /**
5
+ * The bundle as a graph the app can walk: children, routes and edges in both
6
+ * directions. Built once at startup.
7
+ *
8
+ * Holds the bundle's nodes and meta, the semantic index, and lookup tables
9
+ * built from them: child lists, the route of every node, pages by path,
10
+ * entries by `path#hash`, and edges by source and by target. `web/main.tsx`
11
+ * creates it from the embedded bundle and `api/source.ts` from a loaded one.
12
+ * The web app, `retrieval/` and the search functions in `query/` read it.
13
+ */
14
+ export declare class Graph {
15
+ readonly meta: BundleMeta;
16
+ /** The embedding model and node vectors for search by meaning, when the page has them. */
17
+ readonly semantic: SemanticIndex | undefined;
18
+ private readonly nodes;
19
+ private readonly childRefs;
20
+ private readonly routes;
21
+ /** Route path to the page it shows. */
22
+ private readonly pages;
23
+ /** `path#hash` to the entry it names: a symbol, a term or a decision. */
24
+ private readonly anchors;
25
+ private readonly outgoing;
26
+ private readonly incoming;
27
+ /**
28
+ * The sections of the bundle, in display order. A bundle that an older
29
+ * version wrote has no `database` section, so a walk over every section
30
+ * goes through this list.
31
+ */
32
+ readonly sections: readonly {
33
+ readonly slug: Section;
34
+ readonly node: NodeRef;
35
+ }[];
36
+ /** Indexes the nodes and edges of a bundle. */
37
+ constructor(bundle: DocsBundle);
38
+ /** Returns the node at `ref`, and throws when there is none. */
39
+ node(ref: NodeRef): GraphNode;
40
+ /** Returns the children of a node in display order. */
41
+ children(ref: NodeRef): readonly NodeRef[];
42
+ /** From the section down to the parent of `ref`. */
43
+ ancestors(ref: NodeRef): NodeRef[];
44
+ /** Returns the route of the page that shows a node, and throws when there is no node at `ref`. */
45
+ route(ref: NodeRef): Route;
46
+ /** The node a location shows: the entry `hash` names on the page at `path`, else that page. */
47
+ at(path: string, hash?: string): NodeRef | undefined;
48
+ /** Returns the root node of a section, and throws when the bundle lacks it. */
49
+ section(slug: Section): NodeRef;
50
+ /** The section a node is in. */
51
+ sectionOf(ref: NodeRef): NodeRef;
52
+ /** Every node below `ref`, depth first, in display order. */
53
+ descendants(ref: NodeRef): Generator<NodeRef>;
54
+ /** Number of nodes below `ref` whose kind is one of `kinds`. */
55
+ count(ref: NodeRef, kinds: ReadonlySet<NodeKind>): number;
56
+ /** Returns the edges that start at a node. */
57
+ edgesFrom(ref: NodeRef): readonly Edge[];
58
+ /** Returns the edges that end at a node. */
59
+ edgesTo(ref: NodeRef): readonly Edge[];
60
+ /**
61
+ * Name of a node as other places refer to it: `Class.method` for a symbol,
62
+ * `Class.method(parameter)` for a parameter, `table.column` for a column,
63
+ * `query(:placeholder)` for a placeholder of a query, the file path for a page.
64
+ */
65
+ qualifiedName(ref: NodeRef): string;
66
+ }
@@ -0,0 +1,4 @@
1
+ export { Graph, isDeclarationKind } from './graph';
2
+ export { buildSearchIndex, type SearchEntry, type SearchMatch, search } from './name-search';
3
+ export { embeddingModelName, type MeaningOptions, searchByMeaning, similarNodes } from './semantic';
4
+ export { codeText, firstParagraph, plainText } from './text';
@@ -0,0 +1,47 @@
1
+ import { type NodeKind, type NodeRef } from '../model';
2
+ import type { Graph } from './graph';
3
+ /** What search by words knows about one page or entry. */
4
+ export interface SearchEntry {
5
+ readonly node: NodeRef;
6
+ readonly kind: NodeKind;
7
+ /** Name of the section the node is in. Results are grouped by it. */
8
+ readonly group: string;
9
+ readonly title: string;
10
+ readonly detail: string;
11
+ /** Lowercase text that names the node: its title, the words of its name, the words it replaces. */
12
+ readonly haystack: string;
13
+ /** Lowercase words of `detail`, each with a space in front of it. */
14
+ readonly place: string;
15
+ /**
16
+ * Lowercase words that describe the node: its description, its definition,
17
+ * the page. Every word has a space in front of it, so a search can tell the
18
+ * start of a word from its middle.
19
+ */
20
+ readonly text: string;
21
+ }
22
+ /** One result of a search by words. */
23
+ export interface SearchMatch {
24
+ readonly entry: SearchEntry;
25
+ /** `name`: every word of the query is in what names the node. `text`: at least one is only in what describes it. */
26
+ readonly found: 'name' | 'text';
27
+ }
28
+ /**
29
+ * Builds the index for search by words: one entry per file, symbol, glossary
30
+ * term, decision, API operation, schema definition, table and query. Folders,
31
+ * parameters and fields are not searched.
32
+ *
33
+ * @returns The entries in display order.
34
+ */
35
+ export declare function buildSearchIndex(graph: Graph): SearchEntry[];
36
+ /**
37
+ * Finds the entries that contain every word of a query. Entries that are
38
+ * named by the words come first: an exact title, then a title that starts
39
+ * with the query, then other names. Entries in a file whose path holds a
40
+ * word follow, then entries that mention a word in their description. A word
41
+ * of the query may be the start of a word of the description.
42
+ *
43
+ * @param index - The index from `buildSearchIndex`.
44
+ * @param query - What the reader typed.
45
+ * @returns The matches, best first.
46
+ */
47
+ export declare function search(index: readonly SearchEntry[], query: string, limit: number): SearchMatch[];
@@ -0,0 +1,30 @@
1
+ import { type SemanticHit } from '../embeddings';
2
+ import { type NodeRef } from '../model';
3
+ import type { Graph } from './graph';
4
+ /** Narrows a search by meaning. */
5
+ export interface MeaningOptions {
6
+ /** Most hits to return. Default: the number the search dialog shows. */
7
+ readonly limit?: number;
8
+ /** Says which nodes count. Default: every node. */
9
+ readonly accepts?: (node: NodeRef) => boolean;
10
+ }
11
+ /**
12
+ * Finds nodes by the meaning of a query, such as the term `Sailing` for the query `ship`.
13
+ *
14
+ * @param query - What the reader typed.
15
+ * @param exclude - Nodes that are listed already.
16
+ * @returns The closest nodes, best first. Empty for a graph without embeddings.
17
+ */
18
+ export declare function searchByMeaning(graph: Graph, query: string, exclude: ReadonlySet<NodeRef>, options?: MeaningOptions): SemanticHit[];
19
+ /**
20
+ * Finds the nodes whose meaning is closest to that of a node.
21
+ *
22
+ * @returns The closest nodes, best first. Empty for a graph without embeddings.
23
+ */
24
+ export declare function similarNodes(graph: Graph, node: NodeRef): SemanticHit[];
25
+ /**
26
+ * Names the embedding model of a graph.
27
+ *
28
+ * @returns The name, or `null` for a graph without embeddings.
29
+ */
30
+ export declare function embeddingModelName(graph: Graph): string | null;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Reduces scanner HTML to the text a reader sees, on one line.
3
+ *
4
+ * @param html - HTML of a description or a page.
5
+ * @returns The text without tags, with whitespace collapsed. Inline tags leave no gap, so `<code>a</code>.` reads `a.`
6
+ */
7
+ export declare function plainText(html: string): string;
8
+ /**
9
+ * Reads source code back out of a highlighted `<pre>` block.
10
+ *
11
+ * @param html - HTML of a signature, an example or a file shown as text.
12
+ * @returns The code with its line breaks, without the highlighting.
13
+ */
14
+ export declare function codeText(html: string): string;
15
+ /**
16
+ * Takes the first paragraph of a description as its summary.
17
+ *
18
+ * @param html - HTML of a description or a page.
19
+ * @param maxLength - Longest summary. A longer paragraph is cut at a word and ends with `...`.
20
+ * @returns The paragraph as plain text, or `''` when the HTML has no paragraph.
21
+ */
22
+ export declare function firstParagraph(html: string, maxLength?: number): string;