@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,560 @@
1
+ import { type EdgeKind, type KindsIn, type NodeKind, type Section } from './registry';
2
+ /** Index of a node in {@link DocsBundle.nodes}. */
3
+ export type NodeRef = number;
4
+ export { ALL_NODE_KINDS, EDGE_KINDS, type EdgeKind, kindsIn, kindsWith, NODE_KINDS, type NodeGroup, type NodeKind, type NodeKindSpec, RELATION_FAMILIES, RELATION_FAMILY_NAMES, RELATION_KINDS, type RelationFamily, type RelationFamilySpec, type RelationKindSpec, SECTION_SPECS, SECTIONS, type Section, type SectionSpec, } from './registry';
5
+ /** Kinds of a declaration in code. */
6
+ export declare const SYMBOL_KINDS: readonly KindsIn<"symbol">[];
7
+ /** A kind of a declaration in code. */
8
+ export type SymbolKind = KindsIn<'symbol'>;
9
+ /** Kinds a type name can refer to. */
10
+ export declare const TYPE_KINDS: ReadonlySet<SymbolKind>;
11
+ /** Kinds that own member symbols. */
12
+ export declare const CONTAINER_KINDS: ReadonlySet<SymbolKind>;
13
+ /**
14
+ * Kinds of a file that has a page. See `NODE_KIND_REGISTRY` for what each one is.
15
+ * A `glossary`, `decisions`, `schema`, `api`, `database` or `catalog` node has its entries as children.
16
+ */
17
+ export declare const FILE_KINDS: readonly KindsIn<"file">[];
18
+ /** A kind of a file that has a page. */
19
+ export type FileKind = KindsIn<'file'>;
20
+ /**
21
+ * Kinds shown as an **entry**: a block on the page of the file they are in,
22
+ * with an anchor of its own. Symbols are entries of a source file, terms of a
23
+ * glossary, decisions of a decision log, operations of an OpenAPI document,
24
+ * definitions of an OpenAPI document or a JSON Schema, tables of a database,
25
+ * queries of a query catalog.
26
+ */
27
+ export declare const ENTRY_KINDS: readonly KindsIn<"entry" | "symbol">[];
28
+ /** A kind shown as an entry. */
29
+ export type EntryKind = KindsIn<'symbol' | 'entry'>;
30
+ /** Kinds a node with an id can have: every kind but parameter and field. */
31
+ export declare const LISTED_KINDS: readonly KindsIn<"entry" | "file" | "folder" | "section" | "source" | "symbol">[];
32
+ /** Tells a symbol kind from the others. */
33
+ export declare function isSymbolKind(kind: NodeKind): kind is SymbolKind;
34
+ /** Tells the kind of a file with a page from the others. */
35
+ export declare function isFileKind(kind: NodeKind): kind is FileKind;
36
+ /** Tells an entry kind, a symbol included, from the others. */
37
+ export declare function isEntryKind(kind: NodeKind): kind is EntryKind;
38
+ /** What every node states, whatever its kind. */
39
+ interface NodeBase<K extends NodeKind> {
40
+ readonly kind: K;
41
+ /** Shown in the tree: a file name, a symbol name, a parameter name. */
42
+ readonly name: string;
43
+ /** The node this one belongs to. `null` for a section. */
44
+ readonly parent: NodeRef | null;
45
+ /** Segment of the node's route. Defaults to `name`. */
46
+ readonly slug?: string;
47
+ }
48
+ /** One of the top-level groups. */
49
+ export interface SectionNode extends NodeBase<'section'> {
50
+ readonly slug: Section;
51
+ }
52
+ /** A directory of the scanned repository. */
53
+ export type FolderNode = NodeBase<'folder'>;
54
+ /** A heading of a markdown page, for its table of contents. `id` is the anchor of the heading. */
55
+ export interface Heading {
56
+ readonly id: string;
57
+ readonly text: string;
58
+ readonly depth: number;
59
+ }
60
+ /** What a file looks like on its page. */
61
+ export type FileContent = {
62
+ readonly format: 'markdown';
63
+ readonly html: string;
64
+ readonly headings: readonly Heading[];
65
+ }
66
+ /** A `<pre>` block, highlighted when the file is small enough. */
67
+ | {
68
+ readonly format: 'text';
69
+ readonly html: string;
70
+ }
71
+ /** `src` is a `data:` URI. */
72
+ | {
73
+ readonly format: 'image';
74
+ readonly src: string;
75
+ } | {
76
+ readonly format: 'omitted';
77
+ readonly reason: 'binary' | 'large';
78
+ readonly bytes: number;
79
+ };
80
+ /** What every file with a page states. */
81
+ interface FileFacts {
82
+ /** Path as it is on disk, relative to the scanned root. For a `catalog`, the path of its directory. */
83
+ readonly path: string;
84
+ /** Frontmatter `title` or `name`, else the first heading, else the file name. */
85
+ readonly title: string;
86
+ /** Frontmatter `description`, or `''`. */
87
+ readonly description: string;
88
+ readonly content: FileContent;
89
+ }
90
+ /**
91
+ * A file shown as it is. A `skill` node is the skill's `SKILL.md`, and the skill's other files are its descendants.
92
+ * For a `glossary` or `decisions` node, `content` is the text around its entries, and the entries are its children.
93
+ * A `schema` node that is a JSON Schema has its definitions as children.
94
+ * A `catalog` node has no content of its own: its queries are its children.
95
+ */
96
+ export interface FileNode extends NodeBase<Exclude<FileKind, 'api' | 'database' | 'plan' | 'phase'>>, FileFacts {
97
+ }
98
+ /** A base URL an API is served from. */
99
+ export interface ApiServer {
100
+ readonly url: string;
101
+ /** Plain text, or `''`. */
102
+ readonly description: string;
103
+ }
104
+ /** A group of operations of an OpenAPI document. */
105
+ export interface ApiTag {
106
+ readonly name: string;
107
+ readonly descriptionHtml: string;
108
+ }
109
+ /**
110
+ * An OpenAPI document. Its operations and its schema definitions are its
111
+ * children. `title` is the title of the API, `description` its summary, and
112
+ * `content` its description.
113
+ */
114
+ export interface ApiNode extends NodeBase<'api'>, FileFacts {
115
+ /** Version of the API, from `info.version`. */
116
+ readonly version: string;
117
+ /** Version of the OpenAPI format the document is written in, such as `3.1.0`. */
118
+ readonly specVersion: string;
119
+ readonly servers: readonly ApiServer[];
120
+ /** The tags the document declares, in its order. An operation can name a tag that is not listed here. */
121
+ readonly tags: readonly ApiTag[];
122
+ }
123
+ /** A view or a trigger of a database schema. */
124
+ export interface DatabaseObject {
125
+ readonly kind: 'view' | 'trigger';
126
+ readonly name: string;
127
+ /** The table a trigger fires on. `''` for a view. */
128
+ readonly table: string;
129
+ readonly line: number;
130
+ readonly descriptionHtml: string;
131
+ /** The highlighted statement that creates it. */
132
+ readonly sqlHtml: string;
133
+ }
134
+ /**
135
+ * A `.sql` file that creates tables. Its tables are its children. `content`
136
+ * is the comment that opens the file.
137
+ */
138
+ export interface DatabaseNode extends NodeBase<'database'>, FileFacts {
139
+ /** Views and triggers, in file order. */
140
+ readonly objects: readonly DatabaseObject[];
141
+ }
142
+ /** A source file. Its symbols are its descendants. */
143
+ export interface SourceNode extends NodeBase<'source'> {
144
+ readonly path: string;
145
+ readonly language: string;
146
+ /** What the language calls its annotations: `Decorators`, `Attributes` or `Annotations`. */
147
+ readonly annotationLabel: string;
148
+ /** The file's text. Set for a skill's code, `null` in the code section. */
149
+ readonly content: FileContent | null;
150
+ }
151
+ /** `[start, end, target]`: the characters `start` to `end` of a text name the node `target`. */
152
+ export type TextLink = readonly [start: number, end: number, target: NodeRef];
153
+ /** Source text in which some spans name other nodes, such as `Promise<Booking>` with `Booking` linked. */
154
+ export interface LinkedText {
155
+ readonly text: string;
156
+ /** In text order, not overlapping. */
157
+ readonly links: readonly TextLink[];
158
+ }
159
+ /** Doc comment tags that are not folded into parameters, return value or fields. */
160
+ export type DocTagKind = 'throws' | 'deprecated' | 'see' | 'since' | 'other';
161
+ /** A tag of a doc comment, such as `@throws` or `@deprecated`. */
162
+ export interface DocTag {
163
+ readonly kind: DocTagKind;
164
+ /** Original tag label, for example `typeParam`. Set when `kind` is `other`. */
165
+ readonly label?: string;
166
+ /** What the tag is about, such as the exception type of a `throws` tag. */
167
+ readonly subject: LinkedText | null;
168
+ readonly html: string;
169
+ }
170
+ /** What a function returns: its type and the description of its doc comment. */
171
+ export interface ReturnInfo {
172
+ readonly type: LinkedText | null;
173
+ readonly descriptionHtml: string;
174
+ }
175
+ /** A highlighted usage example of a symbol. */
176
+ export interface SymbolExample {
177
+ readonly html: string;
178
+ /** `documented` comes from the doc comment, `generated` from the signature. */
179
+ readonly origin: 'documented' | 'generated';
180
+ }
181
+ /** A class, function or other definition. Its parameters, fields and member symbols are its children. */
182
+ export interface SymbolNode extends NodeBase<SymbolKind> {
183
+ /** Unique within the file and safe in a URL hash. */
184
+ readonly anchor: string;
185
+ readonly line: number;
186
+ /** Highlighted declaration head. Empty for a type the scanner inferred from its members. */
187
+ readonly signatureHtml: string;
188
+ /** Keywords in front of the declaration, such as `export`, `static` or `async`. */
189
+ readonly modifiers: readonly string[];
190
+ /** Decorators, attributes and annotations, verbatim. */
191
+ readonly annotations: readonly string[];
192
+ readonly descriptionHtml: string;
193
+ readonly returns: ReturnInfo | null;
194
+ readonly tags: readonly DocTag[];
195
+ readonly example: SymbolExample | null;
196
+ }
197
+ /** Where an operation of an API takes a parameter from. */
198
+ export type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
199
+ /** What parameters and fields share: a declaration from the signature, a description from the doc comment. */
200
+ interface Declaration {
201
+ readonly type: LinkedText | null;
202
+ /** Default value of a parameter, initializer of a field, value of an enum member. */
203
+ readonly defaultValue: string | null;
204
+ readonly optional: boolean;
205
+ readonly descriptionHtml: string;
206
+ /**
207
+ * The table column a declaration of a query stands for: the column a
208
+ * parameter is compared with or stored in, the column a result column
209
+ * selects. Set when the statement shows one and the scan has that table.
210
+ */
211
+ readonly column?: NodeRef;
212
+ }
213
+ /**
214
+ * A parameter of a function, of a type's constructor, of an API operation or
215
+ * of a query. `name` carries a variadic marker, as in `...rest`, or the
216
+ * marker of a SQL placeholder, as in `:map_id`.
217
+ */
218
+ export interface ParameterNode extends NodeBase<'parameter'>, Declaration {
219
+ /** Set for a parameter of an API operation. */
220
+ readonly location?: ParameterLocation;
221
+ }
222
+ /**
223
+ * A field, property or enum member of a type, a property of a schema
224
+ * definition, a column of a table, or a column of the rows a query returns.
225
+ */
226
+ export interface FieldNode extends NodeBase<'field'>, Declaration {
227
+ /**
228
+ * Further facts about the field, verbatim: annotations in code, constraints
229
+ * of a property such as `format: date`, constraints of a column such as
230
+ * `UNIQUE`, the expression behind a result column such as `COUNT(*)`.
231
+ */
232
+ readonly annotations: readonly string[];
233
+ }
234
+ /** One term of a glossary: a word of the project's language and what it means. */
235
+ export interface TermNode extends NodeBase<'term'> {
236
+ /** Unique within the glossary and safe in a URL hash. */
237
+ readonly anchor: string;
238
+ /** Heading the glossary lists the term under, or `''`. */
239
+ readonly group: string;
240
+ readonly definitionHtml: string;
241
+ /** Words the glossary tells writers to replace with this term. */
242
+ readonly avoid: readonly string[];
243
+ }
244
+ /** One decision of a decision log: what was decided and why. */
245
+ export interface DecisionNode extends NodeBase<'decision'> {
246
+ /** Unique within the log and safe in a URL hash. */
247
+ readonly anchor: string;
248
+ /** Number or id in front of the title, such as `3` or `ADR-0003`. `''` when the title has none. */
249
+ readonly id: string;
250
+ /** As written in the log, such as `accepted` or `superseded by 7`. `''` when the decision states none. */
251
+ readonly status: string;
252
+ /** As written in the log. `''` when the decision states none. */
253
+ readonly date: string;
254
+ readonly html: string;
255
+ }
256
+ /** One media type of a request body or a response, with the schema of its content. */
257
+ export interface ApiContent {
258
+ /** Such as `application/json`. */
259
+ readonly mediaType: string;
260
+ /** The schema as a type expression, such as `Booking[]`. `null` when the document gives none. */
261
+ readonly schema: LinkedText | null;
262
+ }
263
+ /** The request body of an operation. */
264
+ export interface ApiRequestBody {
265
+ readonly required: boolean;
266
+ readonly descriptionHtml: string;
267
+ readonly content: readonly ApiContent[];
268
+ }
269
+ /** One response of an operation. */
270
+ export interface ApiResponse {
271
+ /** Status code or range as the document writes it: `200`, `4XX`, `default`. */
272
+ readonly status: string;
273
+ readonly descriptionHtml: string;
274
+ readonly content: readonly ApiContent[];
275
+ }
276
+ /**
277
+ * One operation of an OpenAPI document: a method on a path, or a webhook.
278
+ * `name` is the method and the path, as in `GET /bookings/{id}`. Its
279
+ * parameters are its children.
280
+ */
281
+ export interface OperationNode extends NodeBase<'operation'> {
282
+ /** Unique within the document and safe in a URL hash. */
283
+ readonly anchor: string;
284
+ /** HTTP method in capitals. */
285
+ readonly method: string;
286
+ /** Path template, such as `/bookings/{id}`. For a webhook, its name. */
287
+ readonly urlPath: string;
288
+ /** `operationId` of the document, or `''`. */
289
+ readonly operationId: string;
290
+ /** Tags the operation is listed under. A webhook without tags is listed under `Webhooks`. */
291
+ readonly tags: readonly string[];
292
+ readonly deprecated: boolean;
293
+ /** One line of plain text, or `''`. */
294
+ readonly summary: string;
295
+ readonly descriptionHtml: string;
296
+ readonly requestBody: ApiRequestBody | null;
297
+ /** In the order of the document. */
298
+ readonly responses: readonly ApiResponse[];
299
+ /**
300
+ * The ways a caller can authenticate, each as the names of the security
301
+ * schemes it needs, joined with ` + `. Empty when the operation is open.
302
+ */
303
+ readonly security: readonly string[];
304
+ }
305
+ /**
306
+ * A named JSON Schema: the root schema of a file, an entry of its `$defs`, or
307
+ * an entry of `components.schemas` of an OpenAPI document. Its properties are
308
+ * its `field` children, nested ones under a dotted name such as `address.city`.
309
+ */
310
+ export interface DefinitionNode extends NodeBase<'definition'> {
311
+ /** Unique within the file and safe in a URL hash. */
312
+ readonly anchor: string;
313
+ /** What the schema allows, as a type expression: `object`, `string[]`, `Cat | Dog`. */
314
+ readonly type: LinkedText | null;
315
+ readonly descriptionHtml: string;
316
+ /** Keywords that narrow the type, verbatim: `format: uuid`, `minimum: 0`. */
317
+ readonly constraints: readonly string[];
318
+ /** The values of an `enum` or a `const`, as JSON. Empty for every other schema. */
319
+ readonly values: readonly string[];
320
+ readonly deprecated: boolean;
321
+ }
322
+ /** A foreign key of a table. */
323
+ export interface ForeignKey {
324
+ /** Name of the constraint, or `''`. */
325
+ readonly name: string;
326
+ /** Columns of this table, in key order. */
327
+ readonly columns: readonly string[];
328
+ /** Name of the referenced table, as the statement writes it. */
329
+ readonly table: string;
330
+ /** The referenced table, when the scan has it. */
331
+ readonly target: NodeRef | null;
332
+ /** Columns of the referenced table, in key order. Its primary key when the statement names none. */
333
+ readonly referencedColumns: readonly string[];
334
+ /** Action in capitals, such as `CASCADE` or `SET NULL`. `''` when the statement states none. */
335
+ readonly onDelete: string;
336
+ readonly onUpdate: string;
337
+ }
338
+ /** An index on a table. */
339
+ export interface TableIndex {
340
+ readonly name: string;
341
+ /** Indexed columns or expressions, in index order. */
342
+ readonly columns: readonly string[];
343
+ readonly unique: boolean;
344
+ }
345
+ /** A table of a database schema. Its columns are its `field` children. */
346
+ export interface TableNode extends NodeBase<'table'> {
347
+ /** Unique within the file and safe in a URL hash. */
348
+ readonly anchor: string;
349
+ readonly line: number;
350
+ readonly descriptionHtml: string;
351
+ /** Columns of the primary key, in key order. Empty for a table without one. */
352
+ readonly primaryKey: readonly string[];
353
+ readonly foreignKeys: readonly ForeignKey[];
354
+ readonly indexes: readonly TableIndex[];
355
+ /** Table constraints that are no key, verbatim: `UNIQUE (a, b)`, `CHECK (a < b)`. */
356
+ readonly constraints: readonly string[];
357
+ /** Table options in capitals: `WITHOUT ROWID`, `STRICT`, `VIRTUAL`. */
358
+ readonly options: readonly string[];
359
+ }
360
+ /**
361
+ * What running an entry of a query catalog does.
362
+ * - `read`: it returns rows and changes nothing, as `SELECT` does.
363
+ * - `write`: it changes rows or the schema, as `INSERT`, `UPDATE`, `DELETE` and `CREATE INDEX` do.
364
+ * - `control`: it changes the state of the transaction or the connection, as `BEGIN`, `COMMIT` and `PRAGMA` do.
365
+ */
366
+ export type QueryEffect = 'read' | 'write' | 'control';
367
+ /** A table an entry of a query catalog names, and what it does with it. */
368
+ export interface QueryTable {
369
+ /** Name of the table, as the statement writes it. */
370
+ readonly name: string;
371
+ /** The table, when the scan has it. */
372
+ readonly target: NodeRef | null;
373
+ readonly access: 'read' | 'write';
374
+ }
375
+ /**
376
+ * One entry of a query catalog: the SQL of one `.sql` file, or of one named
377
+ * block of such a file. `name` is the name the code runs it by: the file name
378
+ * without `.sql`, or the name of the block. Its placeholders are its
379
+ * `parameter` children, and the columns of the rows it returns are its
380
+ * `field` children.
381
+ */
382
+ export interface QueryNode extends NodeBase<'query'> {
383
+ /** Unique within the catalog and safe in a URL hash. */
384
+ readonly anchor: string;
385
+ /** Path of the file the entry is in, relative to the scanned root. */
386
+ readonly sourcePath: string;
387
+ readonly line: number;
388
+ readonly effect: QueryEffect;
389
+ /** The keywords that open the statement, in capitals: `SELECT`, `INSERT`, `BEGIN IMMEDIATE`. */
390
+ readonly verb: string;
391
+ /** The comment above the statement. `''` for an entry without one. */
392
+ readonly descriptionHtml: string;
393
+ /** The highlighted SQL, as the file writes it. */
394
+ readonly sqlHtml: string;
395
+ /** The tables the SQL names, each once per access, in the order they first appear. */
396
+ readonly tables: readonly QueryTable[];
397
+ }
398
+ /** Where a plan, a phase or a task stands, in the order task-manager moves it through. */
399
+ export declare const TASK_STATUSES: readonly ['open', 'in-progress', 'in-review', 'completed', 'blocked'];
400
+ /** One of {@link TASK_STATUSES}. */
401
+ export type TaskStatus = (typeof TASK_STATUSES)[number];
402
+ /** How urgent a plan, a phase or a task is, most urgent first. */
403
+ export declare const TASK_PRIORITIES: readonly ['critical', 'high', 'medium', 'low'];
404
+ /** One of {@link TASK_PRIORITIES}. */
405
+ export type TaskPriority = (typeof TASK_PRIORITIES)[number];
406
+ /** What every plan, phase and task of the task tree states in its frontmatter. */
407
+ interface TrackedFacts {
408
+ readonly status: TaskStatus;
409
+ readonly priority: TaskPriority;
410
+ /** One line of plain text. */
411
+ readonly summary: string;
412
+ /** Names of the plans or phases, or ids of the tasks, this one waits for, as the file writes them. */
413
+ readonly dependsOn: readonly string[];
414
+ }
415
+ /**
416
+ * A plan of the task tree: `<plan>/<plan>.md`. Its phases are its children,
417
+ * and the decision log of its `decisions/` folder when it has one.
418
+ * `name` is the plan's folder name, `title` its title.
419
+ */
420
+ export interface PlanNode extends NodeBase<'plan'>, FileFacts, TrackedFacts {
421
+ }
422
+ /** A phase of a plan: `<plan>/<phase>/<phase>.md`. Its tasks are its children. */
423
+ export interface PhaseNode extends NodeBase<'phase'>, FileFacts, TrackedFacts {
424
+ /** Whether its tasks can run side by side. */
425
+ readonly parallel: boolean;
426
+ }
427
+ /** One task of a phase: `<phase>/tasks/<id>.md`, shown as an entry on the page of its phase. `name` is its title. */
428
+ export interface TaskNode extends NodeBase<'task'>, TrackedFacts {
429
+ /** Unique within the phase and safe in a URL hash. */
430
+ readonly anchor: string;
431
+ /** Such as `TASK-006`. */
432
+ readonly id: string;
433
+ /** Path of the task file, relative to the scanned root. */
434
+ readonly sourcePath: string;
435
+ /** The package the task changes, as the file names it. */
436
+ readonly package: string;
437
+ /** From 1 for small to 5 for large. `null` when the file states none. */
438
+ readonly complexity: number | null;
439
+ readonly html: string;
440
+ }
441
+ /** A file node of any kind. */
442
+ export type AnyFileNode = FileNode | ApiNode | DatabaseNode | PlanNode | PhaseNode;
443
+ /** A node of any kind. */
444
+ export type GraphNode = SectionNode | FolderNode | AnyFileNode | SourceNode | SymbolNode | TermNode | DecisionNode | OperationNode | DefinitionNode | TableNode | QueryNode | TaskNode | ParameterNode | FieldNode;
445
+ /** An entry of any kind. */
446
+ export type EntryNode = SymbolNode | TermNode | DecisionNode | OperationNode | DefinitionNode | TableNode | QueryNode | TaskNode;
447
+ /** Tells a symbol node from the others. */
448
+ export declare function isSymbolNode(node: GraphNode): node is SymbolNode;
449
+ /** Tells an entry node, a symbol included, from the others. */
450
+ export declare function isEntryNode(node: GraphNode): node is EntryNode;
451
+ /** Tells a node of a file with a page from the others. */
452
+ export declare function isFileNode(node: GraphNode): node is AnyFileNode;
453
+ /** Kinds of an entry that is described in markdown and can have parameters or fields. */
454
+ export type DescribedNode = SymbolNode | OperationNode | DefinitionNode | TableNode | QueryNode;
455
+ /**
456
+ * Tells the entries with a `descriptionHtml` from the others.
457
+ *
458
+ * @returns True for a symbol, an operation, a definition, a table and a query.
459
+ */
460
+ export declare function isDescribedNode(node: GraphNode): node is DescribedNode;
461
+ /** A relation other than `parent` between two nodes, such as a parameter that has a class as its type. */
462
+ export type Edge = readonly [from: NodeRef, kind: EdgeKind, to: NodeRef];
463
+ /** What the bundle says about its own making. `generatedAt` is an ISO 8601 timestamp. */
464
+ export interface BundleMeta {
465
+ readonly title: string;
466
+ readonly generatedAt: string;
467
+ readonly generator: string;
468
+ }
469
+ /** Version of the layout of {@link SemanticIndex}. A reader skips an index of another version. */
470
+ export declare const SEMANTIC_FORMAT = 3;
471
+ /**
472
+ * What a reader needs to search by meaning: a small text embedding model, one
473
+ * vector per searchable node and the words of each node. An **embedding** is a
474
+ * list of numbers that stands for the meaning of a text. Texts with a similar
475
+ * meaning get similar numbers, so `vessel` is found by a search for `ship`.
476
+ *
477
+ * The model is a table with one vector per word. A contextual model computed
478
+ * each vector in advance, from the word on its own. The vector of a text is
479
+ * the mean of the vectors of its words, so a reader computes it without a
480
+ * neural network and without a server.
481
+ */
482
+ export interface SemanticIndex {
483
+ readonly format: typeof SEMANTIC_FORMAT;
484
+ /** Name of the embedding model, for display. */
485
+ readonly model: string;
486
+ /** Length of every vector. */
487
+ readonly dimensions: number;
488
+ /** The words of the model, joined with `\n`. The line number of a word is its row in `vocabularyVectors`. */
489
+ readonly vocabulary: string;
490
+ /** Base64 of the model table: one row of `dimensions` values per word, each value in four bits. */
491
+ readonly vocabularyVectors: string;
492
+ /** The nodes that have a vector, in the order of `nodeVectors`. */
493
+ readonly nodes: readonly NodeRef[];
494
+ /** Base64 of signed bytes: one vector of length 1 per node, scaled to the range of a signed byte. */
495
+ readonly nodeVectors: string;
496
+ /** Every word that carries meaning in the name or the text of a node, each once, joined with `\n`. */
497
+ readonly words: string;
498
+ /**
499
+ * For each node of `nodes`, the words of its name and the further words of
500
+ * its text, as line numbers in `words`. A one-word query is compared with
501
+ * these words, because the mean of a whole text hides a single word.
502
+ */
503
+ readonly nodeWords: readonly (readonly [name: readonly number[], text: readonly number[]])[];
504
+ }
505
+ /**
506
+ * The data contract between the scanner and the web app: the CLI serializes
507
+ * one bundle into the generated HTML file, and the app reads it back.
508
+ *
509
+ * The bundle is a graph. A **node** is one thing the site shows: a folder, a
510
+ * skill, a document, a class, a parameter, a glossary term, an API operation,
511
+ * a database table, a query. `parent` puts every node in one tree, and that
512
+ * tree is the navigation. An **edge** is any other relation between two nodes,
513
+ * such as "this parameter has that class as its type".
514
+ */
515
+ export interface DocsBundle {
516
+ readonly meta: BundleMeta;
517
+ /** A node comes after its parent, and siblings are in display order. */
518
+ readonly nodes: readonly GraphNode[];
519
+ readonly edges: readonly Edge[];
520
+ /** Left out when the site was generated without embeddings. */
521
+ readonly semantic?: SemanticIndex;
522
+ }
523
+ /** Where a node is shown: a page, and for an entry an anchor on that page. */
524
+ export interface Route {
525
+ /** Slugs from the section down, joined with `/` and not URL-encoded: `code/src/app.ts`. */
526
+ readonly path: string;
527
+ readonly hash?: string;
528
+ }
529
+ /** The part of a node that decides its route. */
530
+ export interface Routable {
531
+ readonly kind: NodeKind;
532
+ readonly name: string;
533
+ readonly parent: NodeRef | null;
534
+ readonly slug?: string;
535
+ readonly anchor?: string;
536
+ }
537
+ /**
538
+ * DOM id and URL hash of an entry on the page of its file: `symbol:App.run`,
539
+ * `term:lane`, `decision:3-use-hash-routes`, `table:Booking`, `query:list_bookings`. The prefix keeps
540
+ * entry anchors apart from heading anchors.
541
+ */
542
+ export declare function entryAnchor(kind: EntryKind, anchor: string): string;
543
+ /**
544
+ * Route of a node. Sections, folders and files are pages. An entry is an
545
+ * anchor on the page of its file, and a parameter or field shares the route
546
+ * of its symbol. The scanner and the web app both use this function.
547
+ */
548
+ export declare function routeOf(nodes: readonly Routable[], ref: NodeRef): Route;
549
+ /** Link to a route from inside the generated page: `#/code/src/app.ts#symbol:App.run`. */
550
+ export declare function hrefOf(route: Route): string;
551
+ /** Id of the `<script type="application/json">` element that holds the bundle. */
552
+ export declare const DATA_ELEMENT_ID = "analyze-data";
553
+ /** Id of the element the app mounts into. */
554
+ export declare const MOUNT_ELEMENT_ID = "analyze-root";
555
+ /** `localStorage` key of the reader's color mode. The template reads it before first paint. */
556
+ export declare const COLOR_MODE_STORAGE_KEY = "analyze:color-mode";
557
+ /** Template marker the CLI replaces with the serialized bundle. Nothing in the web bundle imports it, so the marker stays out of it. */
558
+ export declare const DATA_PLACEHOLDER = "__ANALYZE_DATA__";
559
+ /** Template marker the CLI replaces with the title of the site. Like {@link DATA_PLACEHOLDER}, nothing in the web bundle imports it. */
560
+ export declare const TITLE_PLACEHOLDER = "__ANALYZE_TITLE__";