@g3nomaly/analyze 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/api/bundle-builder.d.ts +29 -10
- package/dist/api/bundle-cache.d.ts +7 -4
- package/dist/api/bundle-loader.d.ts +10 -3
- package/dist/api/create-docs.d.ts +33 -14
- package/dist/api/embedding.d.ts +16 -7
- package/dist/api/errors.d.ts +13 -6
- package/dist/api/list.d.ts +20 -20
- package/dist/api/options.d.ts +18 -22
- package/dist/api/refs.d.ts +24 -21
- package/dist/api/scan.d.ts +24 -12
- package/dist/api/search.d.ts +27 -21
- package/dist/api/services.d.ts +9 -1
- package/dist/api/show.d.ts +15 -19
- package/dist/api/site-reader.d.ts +11 -3
- package/dist/api/site-writer.d.ts +30 -7
- package/dist/api/source.d.ts +23 -12
- package/dist/api/target.d.ts +2 -0
- package/dist/cli.js +670 -238
- package/dist/embeddings/index-builder.d.ts +3 -1
- package/dist/embeddings/model.d.ts +26 -13
- package/dist/embeddings/searcher.d.ts +24 -7
- package/dist/embeddings/vectors.d.ts +3 -1
- package/dist/embeddings/words.d.ts +7 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +647 -229
- package/dist/model/index.d.ts +416 -188
- package/dist/model/registry.d.ts +204 -11
- package/dist/query/graph.d.ts +83 -26
- package/dist/query/name-search.d.ts +39 -21
- package/dist/query/semantic.d.ts +11 -3
- package/dist/retrieval/describe.d.ts +11 -4
- package/dist/retrieval/filter.d.ts +27 -8
- package/dist/retrieval/index.d.ts +1 -1
- package/dist/retrieval/markdown.d.ts +3 -2
- package/dist/retrieval/report.d.ts +147 -70
- package/dist/retrieval/resolve.d.ts +11 -7
- package/dist/retrieval/retriever.d.ts +34 -23
- package/dist/retrieval/summary.d.ts +6 -3
- package/dist/scanner/code/doc/clean.d.ts +31 -5
- package/dist/scanner/code/doc/index.d.ts +7 -1
- package/dist/scanner/code/doc/markdown.d.ts +6 -1
- package/dist/scanner/code/doc/python.d.ts +6 -1
- package/dist/scanner/code/doc/tagged.d.ts +13 -4
- package/dist/scanner/code/doc/types.d.ts +16 -5
- package/dist/scanner/code/doc/xml.d.ts +6 -1
- package/dist/scanner/code/example.d.ts +31 -10
- package/dist/scanner/code/extract.d.ts +56 -21
- package/dist/scanner/code/grammar.d.ts +20 -5
- package/dist/scanner/code/language.d.ts +100 -66
- package/dist/scanner/code/languages/index.d.ts +21 -7
- package/dist/scanner/code/languages/shared.d.ts +23 -4
- package/dist/scanner/code/planner.d.ts +50 -14
- package/dist/scanner/code/symbols.d.ts +86 -20
- package/dist/scanner/code/types.d.ts +48 -15
- package/dist/scanner/config.d.ts +42 -0
- package/dist/scanner/content.d.ts +49 -14
- package/dist/scanner/decisions/parse.d.ts +20 -11
- package/dist/scanner/decisions/planner.d.ts +20 -8
- package/dist/scanner/docs.d.ts +36 -19
- package/dist/scanner/files.d.ts +44 -19
- package/dist/scanner/glossary/parse.d.ts +17 -7
- package/dist/scanner/glossary/planner.d.ts +15 -8
- package/dist/scanner/glossary/terms.d.ts +57 -27
- package/dist/scanner/graph/builder.d.ts +80 -21
- package/dist/scanner/highlight.d.ts +32 -9
- package/dist/scanner/ignore.d.ts +25 -0
- package/dist/scanner/index.d.ts +5 -2
- package/dist/scanner/markdown/frontmatter.d.ts +18 -3
- package/dist/scanner/markdown/links.d.ts +19 -9
- package/dist/scanner/markdown/outline.d.ts +13 -5
- package/dist/scanner/markdown/renderer.d.ts +32 -13
- package/dist/scanner/openapi/planner.d.ts +20 -8
- package/dist/scanner/packages.d.ts +28 -0
- package/dist/scanner/reporter.d.ts +5 -2
- package/dist/scanner/scanner.d.ts +21 -7
- package/dist/scanner/schema/definitions.d.ts +18 -8
- package/dist/scanner/schema/describe.d.ts +44 -18
- package/dist/scanner/schema/planner.d.ts +6 -3
- package/dist/scanner/schema/registry.d.ts +23 -16
- package/dist/scanner/skills/classify.d.ts +2 -1
- package/dist/scanner/skills/layout.d.ts +27 -9
- package/dist/scanner/skills/planner.d.ts +19 -4
- package/dist/scanner/specs.d.ts +8 -2
- package/dist/scanner/sql/catalog.d.ts +21 -7
- package/dist/scanner/sql/cursor.d.ts +9 -4
- package/dist/scanner/sql/database.d.ts +6 -3
- package/dist/scanner/sql/parse.d.ts +62 -27
- package/dist/scanner/sql/planner.d.ts +6 -2
- package/dist/scanner/sql/query.d.ts +34 -21
- package/dist/scanner/sql/registry.d.ts +24 -10
- package/dist/scanner/sql/source.d.ts +1 -0
- package/dist/scanner/sql/statements.d.ts +9 -3
- package/dist/scanner/sql/tokens.d.ts +25 -12
- package/dist/scanner/tasks/layout.d.ts +22 -10
- package/dist/scanner/tasks/planner.d.ts +64 -9
- package/package.json +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type GraphNode, type SemanticIndex } from '../model';
|
|
2
2
|
import type { EmbeddingModel, EmbeddingTable } from './model';
|
|
3
3
|
/**
|
|
4
|
-
* Embeds every searchable node of a scan and packs the result, with the model
|
|
4
|
+
* @brief Embeds every searchable node of a scan and packs the result, with the model
|
|
5
5
|
* itself, into the form a reader loads.
|
|
6
6
|
*
|
|
7
|
+
* @param nodes - Every node of the scan. A node with no searchable text gets no vector.
|
|
8
|
+
* @param model - Model that embeds the texts.
|
|
7
9
|
* @param table - The data of the same model. It travels with the bundle, so a reader can embed a query.
|
|
8
10
|
* @returns The index for `DocsBundle.semantic`.
|
|
9
11
|
*/
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* An embedding model as data: one vector per word.
|
|
3
|
+
*
|
|
4
|
+
* @property name - Name of the model, for display.
|
|
5
|
+
* @property dimensions - Length of every vector.
|
|
6
|
+
* @property vocabulary - The words of the model. The index of a word is its row in `vectors`.
|
|
7
|
+
* @property vectors - One row of `dimensions` small whole numbers per word. The shipped model uses -7 to 7.
|
|
8
|
+
*/
|
|
2
9
|
export interface EmbeddingTable {
|
|
3
|
-
/** Name of the model, for display. */
|
|
4
10
|
readonly name: string;
|
|
5
|
-
/** Length of every vector. */
|
|
6
11
|
readonly dimensions: number;
|
|
7
|
-
/** The words of the model. The index of a word is its row in `vectors`. */
|
|
8
12
|
readonly vocabulary: readonly string[];
|
|
9
|
-
/** One row of `dimensions` small whole numbers per word. The shipped model uses -7 to 7. */
|
|
10
13
|
readonly vectors: Int8Array;
|
|
11
14
|
}
|
|
12
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* One part of a text and how much it counts.
|
|
17
|
+
*
|
|
18
|
+
* @property text - The part, as plain text.
|
|
19
|
+
* @property weight - How much the part counts against the other parts.
|
|
20
|
+
*/
|
|
13
21
|
export interface WeightedText {
|
|
14
22
|
readonly text: string;
|
|
15
23
|
readonly weight: number;
|
|
16
24
|
}
|
|
17
25
|
/**
|
|
18
|
-
* Turns text into an embedding with a table of word vectors.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
26
|
+
* @brief Turns text into an embedding with a table of word vectors.
|
|
27
|
+
*
|
|
28
|
+
* The vector of a word was computed in advance by a contextual model that read the word on
|
|
29
|
+
* its own. The vector of a text is the mean of the vectors of its words. No neural network runs
|
|
30
|
+
* at embedding time: a text is only a sum of table rows.
|
|
22
31
|
*
|
|
23
32
|
* Holds the table's vectors and a `WordVocabulary` over its words.
|
|
24
33
|
* `api/embedding.ts` creates one from the shipped table and passes it to
|
|
@@ -26,6 +35,8 @@ export interface WeightedText {
|
|
|
26
35
|
* `SemanticSearcher` creates one from the table stored in a bundle to embed
|
|
27
36
|
* what a reader types.
|
|
28
37
|
*
|
|
38
|
+
* @property medianLength - Median length of a row of the table, computed on first use.
|
|
39
|
+
*
|
|
29
40
|
* @example
|
|
30
41
|
* const model = new EmbeddingModel({
|
|
31
42
|
* name: index.model,
|
|
@@ -39,11 +50,11 @@ export declare class EmbeddingModel {
|
|
|
39
50
|
readonly dimensions: number;
|
|
40
51
|
private readonly vectors;
|
|
41
52
|
private readonly vocabulary;
|
|
42
|
-
/** Median length of a row of the table. Computed on first use. */
|
|
43
53
|
private medianLength;
|
|
44
54
|
/**
|
|
45
55
|
* Creates a model from its table.
|
|
46
56
|
*
|
|
57
|
+
* @param table - The vectors and the words they belong to.
|
|
47
58
|
* @throws {Error} When the table does not hold one row per word.
|
|
48
59
|
*/
|
|
49
60
|
constructor(table: EmbeddingTable);
|
|
@@ -58,6 +69,7 @@ export declare class EmbeddingModel {
|
|
|
58
69
|
* long description. Each part is embedded on its own, so a short part is
|
|
59
70
|
* not drowned out by a long one.
|
|
60
71
|
*
|
|
72
|
+
* @param parts - The parts of the text, each with its weight.
|
|
61
73
|
* @returns A vector of length 1, or `null` when the model knows no word of any part.
|
|
62
74
|
*/
|
|
63
75
|
embedParts(parts: readonly WeightedText[]): Float32Array | null;
|
|
@@ -78,8 +90,7 @@ export declare class EmbeddingModel {
|
|
|
78
90
|
*/
|
|
79
91
|
wordVector(word: string): Float32Array | null;
|
|
80
92
|
/**
|
|
81
|
-
*
|
|
82
|
-
* a lot a long row, so the length of the row is the weight.
|
|
93
|
+
* Weighs a word of a query by the length of its row in the table.
|
|
83
94
|
*
|
|
84
95
|
* @param word - A word from `contentWords`.
|
|
85
96
|
* @returns The length of the word's row, or the median length for a word the model does not have.
|
|
@@ -95,12 +106,14 @@ export declare class EmbeddingModel {
|
|
|
95
106
|
/**
|
|
96
107
|
* Reads one row of the table.
|
|
97
108
|
*
|
|
109
|
+
* @param row - Index of the row.
|
|
98
110
|
* @returns The values of the row. A view, not a copy.
|
|
99
111
|
*/
|
|
100
112
|
private row;
|
|
101
113
|
/**
|
|
102
114
|
* Measures one row of the table.
|
|
103
115
|
*
|
|
116
|
+
* @param row - Index of the row.
|
|
104
117
|
* @returns The Euclidean length of the row.
|
|
105
118
|
*/
|
|
106
119
|
private lengthOf;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { NodeRef, SemanticIndex } from '../model';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A node and how close its meaning is to the query.
|
|
4
|
+
*
|
|
5
|
+
* @property node - The node the hit is about.
|
|
6
|
+
* @property score - From 0 to 1: 1 is the same meaning, 0 is unrelated.
|
|
7
|
+
*/
|
|
3
8
|
export interface SemanticHit {
|
|
4
9
|
readonly node: NodeRef;
|
|
5
|
-
/** From 0 to 1: 1 is the same meaning, 0 is unrelated. */
|
|
6
10
|
readonly score: number;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
* Finds nodes by meaning in the index of a bundle.
|
|
13
|
+
* @brief Finds nodes by meaning in the index of a bundle.
|
|
10
14
|
*
|
|
11
15
|
* Holds the node vectors and word lists of a `SemanticIndex`, and decodes the
|
|
12
16
|
* `EmbeddingModel` stored in it on the first query. `searcherOf` in
|
|
@@ -14,6 +18,13 @@ export interface SemanticHit {
|
|
|
14
18
|
* for the page and the CLI alike; `scripts/search-benchmark.ts` creates one
|
|
15
19
|
* too. `search` scores every node against a query. `similarTo` compares one
|
|
16
20
|
* node with the others.
|
|
21
|
+
*
|
|
22
|
+
* @property model - The model, decoded on the first query. The model is a few megabytes of text.
|
|
23
|
+
* @property wordVectors - The vector of each word of the index, `null` for a word the model does not have. Filled on the first query.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const searcher = new SemanticSearcher(graph.semantic);
|
|
27
|
+
* searcher.search('ship', 6, 0.5);
|
|
17
28
|
*/
|
|
18
29
|
export declare class SemanticSearcher {
|
|
19
30
|
private readonly index;
|
|
@@ -24,14 +35,16 @@ export declare class SemanticSearcher {
|
|
|
24
35
|
private readonly rows;
|
|
25
36
|
private readonly words;
|
|
26
37
|
private readonly wordIds;
|
|
27
|
-
/** Decoded on the first query. The model is a few megabytes of text. */
|
|
28
38
|
private model;
|
|
29
|
-
/** The vector of each word of the index, `null` for a word the model does not have. Filled on the first query. */
|
|
30
39
|
private wordVectors;
|
|
31
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Creates a searcher for one index.
|
|
42
|
+
*
|
|
43
|
+
* @param index - The index of a bundle, as `DocsBundle.semantic` holds it.
|
|
44
|
+
*/
|
|
32
45
|
constructor(index: SemanticIndex);
|
|
33
46
|
/**
|
|
34
|
-
* Finds the nodes whose meaning is closest to a query.
|
|
47
|
+
* @brief Finds the nodes whose meaning is closest to a query.
|
|
35
48
|
*
|
|
36
49
|
* The score of a node has two parts. One compares the query as a whole
|
|
37
50
|
* with the name and the text of the node as a whole. The other takes each
|
|
@@ -40,6 +53,7 @@ export declare class SemanticSearcher {
|
|
|
40
53
|
* in the model. A one-word query is scored mostly by the second part.
|
|
41
54
|
*
|
|
42
55
|
* @param query - What the reader typed.
|
|
56
|
+
* @param limit - Most hits returned.
|
|
43
57
|
* @param minScore - Hits below this score are left out.
|
|
44
58
|
* @returns The hits, best first.
|
|
45
59
|
*/
|
|
@@ -47,6 +61,8 @@ export declare class SemanticSearcher {
|
|
|
47
61
|
/**
|
|
48
62
|
* Finds the nodes whose meaning is closest to that of a node.
|
|
49
63
|
*
|
|
64
|
+
* @param node - The node to compare the others with.
|
|
65
|
+
* @param limit - Most hits returned.
|
|
50
66
|
* @param minScore - Hits below this score are left out.
|
|
51
67
|
* @returns The hits, best first, without the node itself. Empty when the node has no vector.
|
|
52
68
|
*/
|
|
@@ -60,6 +76,7 @@ export declare class SemanticSearcher {
|
|
|
60
76
|
/**
|
|
61
77
|
* Compares each word of a query with every word of the index.
|
|
62
78
|
*
|
|
79
|
+
* @param model - The model that embeds the words.
|
|
63
80
|
* @param query - What the reader typed.
|
|
64
81
|
* @returns One entry per word of the query that carries meaning.
|
|
65
82
|
*/
|
|
@@ -30,7 +30,7 @@ export declare function similarity(query: Float32Array, rows: Int8Array, row: nu
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function rowOf(rows: Int8Array, row: number, dimensions: number): Float32Array | null;
|
|
32
32
|
/**
|
|
33
|
-
* Stores small whole numbers in four bits each, two per byte. Halves the
|
|
33
|
+
* @brief Stores small whole numbers in four bits each, two per byte. Halves the
|
|
34
34
|
* size of the model table.
|
|
35
35
|
*
|
|
36
36
|
* @param values - Numbers from -8 to 7.
|
|
@@ -41,6 +41,7 @@ export declare function packNibbles(values: Int8Array): Uint8Array;
|
|
|
41
41
|
/**
|
|
42
42
|
* Reads back numbers that `packNibbles` stored.
|
|
43
43
|
*
|
|
44
|
+
* @param packed - Bytes that `packNibbles` wrote.
|
|
44
45
|
* @param count - How many numbers to read.
|
|
45
46
|
* @returns The numbers, from -8 to 7.
|
|
46
47
|
*/
|
|
@@ -48,6 +49,7 @@ export declare function unpackNibbles(packed: Uint8Array, count: number): Int8Ar
|
|
|
48
49
|
/**
|
|
49
50
|
* Encodes bytes as base64 text, for JSON.
|
|
50
51
|
*
|
|
52
|
+
* @param bytes - The bytes to encode.
|
|
51
53
|
* @returns Base64 text.
|
|
52
54
|
*/
|
|
53
55
|
export declare function toBase64(bytes: Int8Array | Uint8Array): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Splits a text into lowercase words and single punctuation marks. Identifiers
|
|
2
|
+
* @brief Splits a text into lowercase words and single punctuation marks. Identifiers
|
|
3
3
|
* are split into their words, accents are dropped, and a short form from code
|
|
4
4
|
* is replaced with the word it stands for, so `srcDir` reads `source`, `directory`.
|
|
5
5
|
*
|
|
@@ -15,12 +15,16 @@ export declare function wordsOf(text: string): string[];
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function isPunctuation(word: string): boolean;
|
|
17
17
|
/**
|
|
18
|
-
* The words an embedding model has a vector for.
|
|
18
|
+
* @brief The words an embedding model has a vector for.
|
|
19
19
|
*
|
|
20
20
|
* Holds a map from each word to its row in the model table. `EmbeddingModel`
|
|
21
21
|
* creates one from its table and uses it to find the row of a word. The
|
|
22
22
|
* scanner side and the page look words up the same way, so a query meets the
|
|
23
23
|
* vectors it was meant for.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const vocabulary = new WordVocabulary(['cat', 'dog']);
|
|
27
|
+
* vocabulary.rowOf('dogs'); // 1, through the stem `dog`
|
|
24
28
|
*/
|
|
25
29
|
export declare class WordVocabulary {
|
|
26
30
|
private readonly rows;
|
|
@@ -31,7 +35,7 @@ export declare class WordVocabulary {
|
|
|
31
35
|
*/
|
|
32
36
|
constructor(words: readonly string[]);
|
|
33
37
|
/**
|
|
34
|
-
* Finds the row that carries the meaning of a word: that of the word
|
|
38
|
+
* @brief Finds the row that carries the meaning of a word: that of the word
|
|
35
39
|
* itself, else that of its stem when the word is a stem with a plain
|
|
36
40
|
* ending, as `sailings` is of `sailing`.
|
|
37
41
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export type { WarningHandler } from './api/options';
|
|
|
5
5
|
export { type RefsOptions, type RefsResult, refs } from './api/refs';
|
|
6
6
|
export { type SearchOptions, type SearchResult, search } from './api/search';
|
|
7
7
|
export { type ShowOptions, show } from './api/show';
|
|
8
|
-
export type { EdgeKind, NodeKind, Section } from './model';
|
|
8
|
+
export type { EdgeKind, NodeKind, NodeType, Section } from './model';
|
|
9
9
|
export type { ContentReport, DatabaseObjectReport, DeclarationReport, NodeReport, NodeSummary, Reference, References, SearchHit, SearchMode, TaskReport, } from './retrieval';
|