@g3nomaly/analyze 0.1.5 → 0.1.7
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 +26 -8
- package/dist/api/create-docs.d.ts +10 -4
- package/dist/api/graph.d.ts +3 -2
- package/dist/api/path.d.ts +150 -0
- package/dist/api/refs.d.ts +32 -15
- package/dist/api/search.d.ts +12 -10
- package/dist/api/target.d.ts +3 -2
- package/dist/cli.js +996 -199
- package/dist/index.d.ts +2 -1
- package/dist/index.js +857 -153
- package/dist/model/index.d.ts +10 -3
- package/dist/model/registry.d.ts +14 -0
- package/dist/query/graph.d.ts +2 -1
- package/dist/query/name-search.d.ts +19 -1
- package/dist/retrieval/describe.d.ts +60 -1
- package/dist/retrieval/graph-export.d.ts +21 -1
- package/dist/retrieval/index.d.ts +6 -5
- package/dist/retrieval/report.d.ts +21 -0
- package/dist/retrieval/resolve.d.ts +25 -1
- package/dist/retrieval/retriever.d.ts +75 -7
- package/dist/retrieval/summary.d.ts +8 -0
- package/dist/retrieval/walk.d.ts +77 -0
- package/dist/scanner/code/calls.d.ts +47 -12
- package/dist/scanner/code/exports.d.ts +70 -0
- package/dist/scanner/code/extract.d.ts +11 -3
- package/dist/scanner/code/imports.d.ts +111 -5
- package/dist/scanner/code/language.d.ts +4 -0
- package/dist/scanner/code/planner.d.ts +2 -1
- package/dist/scanner/code/symbols.d.ts +10 -2
- package/dist/scanner/code/types.d.ts +15 -1
- package/dist/scanner/files.d.ts +3 -1
- package/dist/scanner/graph/builder.d.ts +4 -2
- package/dist/scanner/graph/communities.d.ts +3 -2
- package/dist/scanner/index.d.ts +1 -1
- package/dist/scanner/packages.d.ts +4 -0
- package/package.json +3 -3
package/dist/model/index.d.ts
CHANGED
|
@@ -281,6 +281,7 @@ export interface SymbolExample {
|
|
|
281
281
|
*
|
|
282
282
|
* @property anchor - Unique within the file and safe in a URL hash.
|
|
283
283
|
* @property line - Line of the file where the declaration starts.
|
|
284
|
+
* @property endLine - Line of the file where the declaration ends. Absent in a bundle written before end lines existed.
|
|
284
285
|
* @property signatureHtml - Highlighted declaration head. Empty for a type the scanner inferred from its members.
|
|
285
286
|
* @property modifiers - Keywords in front of the declaration, such as `export`, `static` or `async`.
|
|
286
287
|
* @property annotations - Decorators, attributes and annotations, verbatim.
|
|
@@ -292,6 +293,7 @@ export interface SymbolExample {
|
|
|
292
293
|
export interface SymbolNode extends NodeBase<SymbolKind> {
|
|
293
294
|
readonly anchor: string;
|
|
294
295
|
readonly line: number;
|
|
296
|
+
readonly endLine?: number;
|
|
295
297
|
readonly signatureHtml: string;
|
|
296
298
|
readonly modifiers: readonly string[];
|
|
297
299
|
readonly annotations: readonly string[];
|
|
@@ -659,8 +661,12 @@ export type DescribedNode = SymbolNode | OperationNode | DefinitionNode | TableN
|
|
|
659
661
|
* @returns True for a symbol, an operation, a definition, a table and a query.
|
|
660
662
|
*/
|
|
661
663
|
export declare function isDescribedNode(node: GraphNode): node is DescribedNode;
|
|
662
|
-
/**
|
|
663
|
-
|
|
664
|
+
/**
|
|
665
|
+
* A relation other than `parent` between two nodes, such as a parameter that has a class as its type. `lines` are
|
|
666
|
+
* the lines of the file of `from` where the link is made, in order, such as those of a call or an import. An edge
|
|
667
|
+
* with no line of its own leaves them out.
|
|
668
|
+
*/
|
|
669
|
+
export type Edge = readonly [from: NodeRef, kind: EdgeKind, to: NodeRef, lines?: readonly number[]];
|
|
664
670
|
/**
|
|
665
671
|
* What the bundle says about its own making.
|
|
666
672
|
*
|
|
@@ -717,7 +723,8 @@ export interface SemanticIndex {
|
|
|
717
723
|
*
|
|
718
724
|
* @property labels - Label of each community, by id: the name of its best-linked node. Id 0 is the largest community.
|
|
719
725
|
* @property of - Community id of each node, by `NodeRef`. A parameter or field has the id of the entry it belongs
|
|
720
|
-
* to. `-1` for a section, folder or package,
|
|
726
|
+
* to. `-1` for a section, folder or package, and for a page or entry that would be alone in its community, which
|
|
727
|
+
* belong to none.
|
|
721
728
|
*/
|
|
722
729
|
export interface CommunityIndex {
|
|
723
730
|
readonly labels: readonly string[];
|
package/dist/model/registry.d.ts
CHANGED
|
@@ -508,6 +508,11 @@ export declare const RELATION_FAMILY_REGISTRY: {
|
|
|
508
508
|
readonly description: 'What a source file includes, and what a function calls.';
|
|
509
509
|
readonly colorToken: '--edge-code';
|
|
510
510
|
};
|
|
511
|
+
readonly callback: {
|
|
512
|
+
readonly label: 'callback';
|
|
513
|
+
readonly description: 'A function another function hands on as a value.';
|
|
514
|
+
readonly colorToken: '--edge-callback';
|
|
515
|
+
};
|
|
511
516
|
};
|
|
512
517
|
/** Every relation kind other than `parent`, in the order the site lists them. */
|
|
513
518
|
export declare const RELATION_KIND_REGISTRY: {
|
|
@@ -643,6 +648,15 @@ export declare const RELATION_KIND_REGISTRY: {
|
|
|
643
648
|
readonly family: 'code';
|
|
644
649
|
readonly dashed: true;
|
|
645
650
|
};
|
|
651
|
+
readonly passes: {
|
|
652
|
+
readonly label: 'passes';
|
|
653
|
+
readonly description: 'A function or method hands that function or method on as a value, such as a callback, without calling it.';
|
|
654
|
+
readonly forward: 'passes';
|
|
655
|
+
readonly backward: 'is passed by';
|
|
656
|
+
readonly from: 'function or method';
|
|
657
|
+
readonly to: 'function or method';
|
|
658
|
+
readonly family: 'callback';
|
|
659
|
+
};
|
|
646
660
|
};
|
|
647
661
|
/** Slug of a top-level section, such as `code`. */
|
|
648
662
|
export type Section = keyof typeof SECTION_REGISTRY;
|
package/dist/query/graph.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ export declare class Graph {
|
|
|
60
60
|
* @brief The community a node is in.
|
|
61
61
|
*
|
|
62
62
|
* @param ref - Index of the node in the bundle.
|
|
63
|
-
* @returns The id of its community, or `null` for a section, folder or package, and in a bundle
|
|
63
|
+
* @returns The id of its community, or `null` for a section, folder or package, for a node alone, and in a bundle
|
|
64
|
+
* without communities.
|
|
64
65
|
*/
|
|
65
66
|
communityOf(ref: NodeRef): number | null;
|
|
66
67
|
/**
|
|
@@ -9,7 +9,10 @@ import type { Graph } from './graph';
|
|
|
9
9
|
* @property group - Name of the section the node is in. Results are grouped by it.
|
|
10
10
|
* @property title - Name shown in the results.
|
|
11
11
|
* @property detail - Text shown beside the title, such as a file path.
|
|
12
|
-
* @property haystack - Lowercase text that names the node: its title, the words of its name, the words it replaces
|
|
12
|
+
* @property haystack - Lowercase text that names the node: its title, the words of its name, the words it replaces,
|
|
13
|
+
* and the names of its members.
|
|
14
|
+
* @property own - The part of `haystack` that names the node itself, without its members.
|
|
15
|
+
* @property members - Each parameter, field, operation or definition whose name `haystack` holds, with its own words.
|
|
13
16
|
* @property place - Lowercase words of `detail`, each with a space in front of it.
|
|
14
17
|
* @property text - Lowercase words that describe the node: its description, its definition, the page.
|
|
15
18
|
* Every word has a space in front of it, so a search can tell the start of a word from its middle.
|
|
@@ -24,18 +27,33 @@ export interface SearchEntry {
|
|
|
24
27
|
readonly title: string;
|
|
25
28
|
readonly detail: string;
|
|
26
29
|
readonly haystack: string;
|
|
30
|
+
readonly own: string;
|
|
31
|
+
readonly members: readonly SearchMember[];
|
|
27
32
|
readonly place: string;
|
|
28
33
|
readonly text: string;
|
|
29
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @brief A member whose name is in the entry of its owner.
|
|
37
|
+
*
|
|
38
|
+
* @property node - The member node, such as a field.
|
|
39
|
+
* @property haystack - Lowercase text that names the member, as the member entry holds it.
|
|
40
|
+
*/
|
|
41
|
+
export interface SearchMember {
|
|
42
|
+
readonly node: NodeRef;
|
|
43
|
+
readonly haystack: string;
|
|
44
|
+
}
|
|
30
45
|
/**
|
|
31
46
|
* One result of a search by words.
|
|
32
47
|
*
|
|
33
48
|
* @property entry - The entry that matched.
|
|
34
49
|
* @property found - `name` when every word of the query is in what names the node. `text` when at least one word is only in what describes it.
|
|
50
|
+
* @property member - For a match by name that needs the name of a member, the first member whose words, with the
|
|
51
|
+
* node's own, hold every word of the query. `null` when the node's own name holds them, and for a match by text.
|
|
35
52
|
*/
|
|
36
53
|
export interface SearchMatch {
|
|
37
54
|
readonly entry: SearchEntry;
|
|
38
55
|
readonly found: 'name' | 'text';
|
|
56
|
+
readonly member: NodeRef | null;
|
|
39
57
|
}
|
|
40
58
|
/**
|
|
41
59
|
* @brief Builds the index for search by words: one entry per file, symbol, glossary term, decision, table,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EdgeKind, type NodeRef } from '../model';
|
|
2
2
|
import { type Graph } from '../query';
|
|
3
|
-
import type { NodeReport, References } from './report';
|
|
3
|
+
import type { NodeReport, Reference, References } from './report';
|
|
4
4
|
/**
|
|
5
5
|
* @brief Which edges of a node to report.
|
|
6
6
|
*
|
|
@@ -13,6 +13,65 @@ export interface ReferenceOptions {
|
|
|
13
13
|
}
|
|
14
14
|
/** The options that keep every edge in both directions. */
|
|
15
15
|
export declare const ALL_REFERENCES: ReferenceOptions;
|
|
16
|
+
/**
|
|
17
|
+
* @brief One edge of a node, seen from the node: the relation, the page or entry at the other end, and the
|
|
18
|
+
* parameter or field it runs through.
|
|
19
|
+
*
|
|
20
|
+
* @property relation - Kind of the edge.
|
|
21
|
+
* @property node - The page or entry at the other end. A parameter or field there counts as its symbol.
|
|
22
|
+
* @property via - For a `type` edge, the name of the parameter or field of the node it starts at, else `null`.
|
|
23
|
+
* @property source - Node the edge starts at, whose file holds `lines`.
|
|
24
|
+
* @property lines - Lines where the link is made, of every edge the step stands for, in order. Empty when the
|
|
25
|
+
* edges record none.
|
|
26
|
+
*/
|
|
27
|
+
export interface Step {
|
|
28
|
+
readonly relation: EdgeKind;
|
|
29
|
+
readonly node: NodeRef;
|
|
30
|
+
readonly via: string | null;
|
|
31
|
+
readonly source: NodeRef;
|
|
32
|
+
readonly lines: readonly number[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @brief Lists the edges of a node in one direction, each once. The edges of its parameters and fields count as its
|
|
36
|
+
* own, as on its page.
|
|
37
|
+
*
|
|
38
|
+
* @param graph - Graph the node belongs to.
|
|
39
|
+
* @param node - A page or an entry.
|
|
40
|
+
* @param direction - `out` for the edges that start at the node, `in` for those that end at it.
|
|
41
|
+
* @param kinds - Edge kinds to keep. Empty keeps every kind.
|
|
42
|
+
* @returns The steps in edge order.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stepsOf(graph: Graph, node: NodeRef, direction: 'in' | 'out', kinds: readonly EdgeKind[]): Step[];
|
|
45
|
+
/**
|
|
46
|
+
* @brief Finds the file a node is in: the node itself when it is a file or a source file, else its closest such
|
|
47
|
+
* ancestor.
|
|
48
|
+
*
|
|
49
|
+
* @param graph - Graph the node belongs to.
|
|
50
|
+
* @param node - Any node.
|
|
51
|
+
* @returns The file, or the node itself when no file holds it, as for a folder or a package.
|
|
52
|
+
*/
|
|
53
|
+
export declare function fileOf(graph: Graph, node: NodeRef): NodeRef;
|
|
54
|
+
/**
|
|
55
|
+
* @brief Lists the links of a file to other files in one direction, as the file level of the graph page draws
|
|
56
|
+
* them: every edge of the file and of the entries in it counts for the file, and every edge to another file or an
|
|
57
|
+
* entry in it counts for that file. Edges inside the file are left out. Nothing is stored for these links.
|
|
58
|
+
*
|
|
59
|
+
* @param graph - Graph the file belongs to.
|
|
60
|
+
* @param file - A file, as `fileOf` gives it.
|
|
61
|
+
* @param direction - `out` for what the file links to, `in` for what links to it.
|
|
62
|
+
* @param kinds - Edge kinds to keep. Empty keeps every kind.
|
|
63
|
+
* @returns One step per other file and edge kind, with the lines of every edge it stands for.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fileStepsOf(graph: Graph, file: NodeRef, direction: 'in' | 'out', kinds: readonly EdgeKind[]): Step[];
|
|
66
|
+
/**
|
|
67
|
+
* @brief Turns a step into the reference a report shows.
|
|
68
|
+
*
|
|
69
|
+
* @param graph - Graph the step belongs to.
|
|
70
|
+
* @param step - The step.
|
|
71
|
+
* @returns The relation, the summary of the other node, the parameter or field it runs through, and where the link
|
|
72
|
+
* is made.
|
|
73
|
+
*/
|
|
74
|
+
export declare function referenceOf(graph: Graph, step: Step): Reference;
|
|
16
75
|
/**
|
|
17
76
|
* @brief Lists the edges of a node in both directions. The edges of its parameters
|
|
18
77
|
* and fields count as its own, as on its page.
|
|
@@ -30,9 +30,13 @@ export interface GraphExportOptions {
|
|
|
30
30
|
* @property type - Type of the node, such as `source` or `method`.
|
|
31
31
|
* @property name - Name of the node. For a package, the name its manifest gives.
|
|
32
32
|
* @property package - Display path of the package the node is or is in, such as `libs/slam`, or `null`.
|
|
33
|
-
* @property community - Id of the community of the node, or `null` for a section, folder or package
|
|
33
|
+
* @property community - Id of the community of the node, or `null` for a section, folder or package and for a node
|
|
34
|
+
* that would be alone in one.
|
|
34
35
|
* @property parent - Id of the node it is drawn in, such as the folder of a file, or `null`. Always `null` at the
|
|
35
36
|
* `packages` and `communities` levels.
|
|
37
|
+
* @property size - For a community: the number of pages and entries in it. Absent on every other node.
|
|
38
|
+
* @property members - For a community: its best-linked pages and entries, the best first, at most
|
|
39
|
+
* `COMMUNITY_MEMBERS`. Absent on every other node.
|
|
36
40
|
*/
|
|
37
41
|
export interface ExportNode {
|
|
38
42
|
readonly id: string;
|
|
@@ -42,7 +46,23 @@ export interface ExportNode {
|
|
|
42
46
|
readonly package: string | null;
|
|
43
47
|
readonly community: number | null;
|
|
44
48
|
readonly parent: string | null;
|
|
49
|
+
readonly size?: number;
|
|
50
|
+
readonly members?: readonly CommunityMember[];
|
|
45
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @brief A page or entry of a community, as the export of the community lists it.
|
|
54
|
+
*
|
|
55
|
+
* @property id - Id of the node, as `show` and `refs` take it.
|
|
56
|
+
* @property name - Path of a file, or the qualified name of an entry, such as `Retriever.search`.
|
|
57
|
+
* @property links - Number of edges of the node, both ways, that the `all` level of the graph page draws.
|
|
58
|
+
*/
|
|
59
|
+
export interface CommunityMember {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly links: number;
|
|
63
|
+
}
|
|
64
|
+
/** Most members the export of one community lists. */
|
|
65
|
+
export declare const COMMUNITY_MEMBERS = 5;
|
|
46
66
|
/**
|
|
47
67
|
* @brief Edges of one kind between two nodes of an export.
|
|
48
68
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { ALL_REFERENCES, describeNode, type ReferenceOptions, referencesOf } from './describe';
|
|
1
|
+
export { ALL_REFERENCES, describeNode, fileOf, type ReferenceOptions, referencesOf } from './describe';
|
|
2
|
+
export { DEFAULT_WALK_LIMIT, shortestPath, WALK_LEVELS, type Walk, type WalkLevel, type WalkOptions, type WalkReference, walkReferences, } from './walk';
|
|
2
3
|
export { NO_FILTER, type NodeFilter, nodeTest, resultOf, resultsOf } from './filter';
|
|
3
|
-
export { EXPORT_LEVELS, type ExportEdge, type ExportLevel, type ExportNode, type GraphExport, type GraphExportOptions, exportGraph, } from './graph-export';
|
|
4
|
+
export { COMMUNITY_MEMBERS, type CommunityMember, EXPORT_LEVELS, type ExportEdge, type ExportLevel, type ExportNode, type GraphExport, type GraphExportOptions, exportGraph, } from './graph-export';
|
|
4
5
|
export { codeBlock, htmlToMarkdown } from './markdown';
|
|
5
|
-
export type { ContentReport, DatabaseObjectReport, DeclarationReport, ForeignKeyReport, NodeReport, NodeSummary, OperationReport, QueryReport, Reference, References, TableReport, TagReport, TaskReport, } from './report';
|
|
6
|
-
export { type Resolution, resolveNode } from './resolve';
|
|
7
|
-
export { Retriever, SEARCH_MODES, type SearchHit, type SearchMode, type SearchOptions } from './retriever';
|
|
6
|
+
export type { ContentReport, DatabaseObjectReport, DeclarationReport, MemberMatch, ForeignKeyReport, NodeReport, NodeSummary, OperationReport, QueryReport, Reference, References, TableReport, TagReport, TaskReport, } from './report';
|
|
7
|
+
export { type Candidate, closestNames, type Resolution, resolveNode } from './resolve';
|
|
8
|
+
export { type HitPlace, Retriever, SEARCH_MODES, type SearchHit, type SearchMode, type SearchOptions } from './retriever';
|
|
8
9
|
export { nodeId, normalizeId, summarize } from './summary';
|
|
@@ -9,6 +9,8 @@ import type { ApiServer, DocTagKind, EdgeKind, NodeKind, NodeType, PackageRole,
|
|
|
9
9
|
* @property note - A short fact that belongs beside the title: the status of a decision, a plan, a phase or a task, the language of a source file, the version of an API, the verb of a query. `''` for other nodes.
|
|
10
10
|
* @property path - Path on disk of the file the node is or is in. For a catalog, the path of its directory. `null` for a section or a folder.
|
|
11
11
|
* @property line - Line of a symbol, a table or a query in its file. `null` for every other node.
|
|
12
|
+
* @property endLine - Last line of a symbol in its file. `null` for every other node, and for a symbol of a site
|
|
13
|
+
* written before end lines existed.
|
|
12
14
|
* @property summary - First paragraph of its description, as plain text. A table or a query without a description gets what its SQL states instead: the number of columns and the tables it is connected to, or the tables it reads and writes. `''` for any other node without a description.
|
|
13
15
|
*/
|
|
14
16
|
export interface NodeSummary {
|
|
@@ -19,8 +21,20 @@ export interface NodeSummary {
|
|
|
19
21
|
readonly note: string;
|
|
20
22
|
readonly path: string | null;
|
|
21
23
|
readonly line: number | null;
|
|
24
|
+
readonly endLine: number | null;
|
|
22
25
|
readonly summary: string;
|
|
23
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @brief The parameter, field, operation or definition of a node that a name or a search matched, when the node's
|
|
29
|
+
* own name did not.
|
|
30
|
+
*
|
|
31
|
+
* @property kind - Kind of the member, such as `field`.
|
|
32
|
+
* @property name - Name of the member, such as `hashFile`.
|
|
33
|
+
*/
|
|
34
|
+
export interface MemberMatch {
|
|
35
|
+
readonly kind: NodeKind;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
}
|
|
24
38
|
/**
|
|
25
39
|
* @brief A parameter or a field of a symbol, a parameter of an operation, a property of a definition, a column of a table, or a placeholder or a result column of a query.
|
|
26
40
|
*
|
|
@@ -175,11 +189,18 @@ export interface TagReport {
|
|
|
175
189
|
* @property relation - Kind of the edge.
|
|
176
190
|
* @property node - The node at the other end. For a parameter or a field, the symbol that declares it.
|
|
177
191
|
* @property via - Name of the parameter or field the edge starts at, when it does not start at a page or an entry.
|
|
192
|
+
* @property location - Where the link is made: the file of the node the edge starts at and the lines in it, e.g.
|
|
193
|
+
* `{ path: "packages/core/src/cli/commands/add.ts", lines: [86] }` for a call. `null` when the edge records no
|
|
194
|
+
* lines.
|
|
178
195
|
*/
|
|
179
196
|
export interface Reference {
|
|
180
197
|
readonly relation: EdgeKind;
|
|
181
198
|
readonly node: NodeSummary;
|
|
182
199
|
readonly via: string | null;
|
|
200
|
+
readonly location: {
|
|
201
|
+
readonly path: string;
|
|
202
|
+
readonly lines: readonly number[];
|
|
203
|
+
} | null;
|
|
183
204
|
}
|
|
184
205
|
/**
|
|
185
206
|
* @brief Both directions of the edges of a node.
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { type NodeRef } from '../model';
|
|
2
2
|
import type { Graph } from '../query';
|
|
3
|
+
/**
|
|
4
|
+
* @brief One node a name fits, with the parameter, field, operation or definition of it that the name matched.
|
|
5
|
+
*
|
|
6
|
+
* @property node - The node.
|
|
7
|
+
* @property member - The member whose name matched, such as the field `hashFile` of an interface. `null` when the
|
|
8
|
+
* name of the node itself matched.
|
|
9
|
+
*/
|
|
10
|
+
export interface Candidate {
|
|
11
|
+
readonly node: NodeRef;
|
|
12
|
+
readonly member: NodeRef | null;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* @brief What a reference to a node turned out to name.
|
|
5
16
|
*
|
|
@@ -11,7 +22,7 @@ export type Resolution = {
|
|
|
11
22
|
readonly node: NodeRef;
|
|
12
23
|
} | {
|
|
13
24
|
readonly kind: 'ambiguous';
|
|
14
|
-
readonly candidates: readonly
|
|
25
|
+
readonly candidates: readonly Candidate[];
|
|
15
26
|
} | {
|
|
16
27
|
readonly kind: 'missing';
|
|
17
28
|
};
|
|
@@ -29,3 +40,16 @@ export type Resolution = {
|
|
|
29
40
|
* @returns The node, the candidates when several fit the deciding rule, or `missing`. A match by name on a parameter, field, operation or definition returns the node it belongs to, see `resultOf`; its id returns the node itself.
|
|
30
41
|
*/
|
|
31
42
|
export declare function resolveNode(graph: Graph, text: string, accepts: (node: NodeRef) => boolean): Resolution;
|
|
43
|
+
/**
|
|
44
|
+
* @brief Finds the names closest to a name that fits no node, such as `installSkillPackages` for
|
|
45
|
+
* `instalSkillPackages`, capitals ignored.
|
|
46
|
+
*
|
|
47
|
+
* A name counts when at most one edit in four characters turns it into the text, and at least one edit always
|
|
48
|
+
* counts.
|
|
49
|
+
*
|
|
50
|
+
* @param graph - Graph to search.
|
|
51
|
+
* @param text - The name that fit no node.
|
|
52
|
+
* @param accepts - Narrows the nodes that count, such as to one kind.
|
|
53
|
+
* @returns Up to three names, the closest first. Empty when none is close.
|
|
54
|
+
*/
|
|
55
|
+
export declare function closestNames(graph: Graph, text: string, accepts: (node: NodeRef) => boolean): string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EdgeKind, type NodeRef, type Section } from '../model';
|
|
2
2
|
import { type Graph } from '../query';
|
|
3
|
-
import { type ReferenceOptions } from './describe';
|
|
4
3
|
import { type NodeFilter } from './filter';
|
|
5
4
|
import { type GraphExport, type GraphExportOptions } from './graph-export';
|
|
6
|
-
import type { NodeReport, NodeSummary,
|
|
5
|
+
import type { MemberMatch, NodeReport, NodeSummary, Reference } from './report';
|
|
7
6
|
import { type Resolution } from './resolve';
|
|
7
|
+
import { type Walk, type WalkOptions } from './walk';
|
|
8
8
|
/** The search modes a caller can pick from, the default first. */
|
|
9
9
|
export declare const SEARCH_MODES: readonly ['both', 'name', 'meaning'];
|
|
10
10
|
/** How a search matches: `name` by the words of a name or a description, `meaning` by the embedding model, `both` by words first and then by meaning. */
|
|
@@ -27,11 +27,30 @@ export interface SearchOptions {
|
|
|
27
27
|
* @property match - `name`: every word of the query is in the name or the path of the node. `text`: at least one word is only in its description. `meaning`: the node is close to the query in the embedding model.
|
|
28
28
|
* @property score - From 0 to 1 for a match by meaning. `null` for a match by words.
|
|
29
29
|
* @property weak - `true` for a match by meaning below the cut-off, which only a search that found nothing else returns. Absent on every other hit.
|
|
30
|
+
* @property member - The parameter, field, operation or definition of the node that matched, such as the field
|
|
31
|
+
* `hashFile` of an interface. `null` when the node matched by its own name, text or meaning.
|
|
32
|
+
* @property section - Section the node is in.
|
|
33
|
+
* @property duplicates - Other nodes the same search found that this hit stands for, because they match the same way
|
|
34
|
+
* with the same kind, type, title, summary and score, such as nine `hooks.json` files that say nothing. Each with
|
|
35
|
+
* its id and path. Empty for a hit that stands for itself only.
|
|
30
36
|
*/
|
|
31
37
|
export interface SearchHit extends NodeSummary {
|
|
32
38
|
readonly match: 'name' | 'text' | 'meaning';
|
|
33
39
|
readonly score: number | null;
|
|
34
40
|
readonly weak?: true;
|
|
41
|
+
readonly member: MemberMatch | null;
|
|
42
|
+
readonly section: Section;
|
|
43
|
+
readonly duplicates: readonly HitPlace[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @brief Where a node a search hit stands for is.
|
|
47
|
+
*
|
|
48
|
+
* @property id - Id of the node.
|
|
49
|
+
* @property path - Path on disk of the file the node is or is in, or `null`.
|
|
50
|
+
*/
|
|
51
|
+
export interface HitPlace {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly path: string | null;
|
|
35
54
|
}
|
|
36
55
|
/**
|
|
37
56
|
* @brief Answers queries on one bundle: search, list, look up, describe, export.
|
|
@@ -58,6 +77,12 @@ export declare class Retriever {
|
|
|
58
77
|
* @returns The name, or `null` when the bundle was built without embeddings.
|
|
59
78
|
*/
|
|
60
79
|
get model(): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* @brief Lists the sections the bundle has, in display order. A bundle can lack one, such as `database`.
|
|
82
|
+
*
|
|
83
|
+
* @returns The slugs of its sections.
|
|
84
|
+
*/
|
|
85
|
+
get sections(): readonly Section[];
|
|
61
86
|
/**
|
|
62
87
|
* @brief Finds pages and entries for a query. Matches by words come first, in the
|
|
63
88
|
* order the site lists them. Matches by meaning follow, best first.
|
|
@@ -76,6 +101,17 @@ export declare class Retriever {
|
|
|
76
101
|
* @returns The hits, best first, each with `weak: true`. Empty for a search by name or a bundle without embeddings.
|
|
77
102
|
*/
|
|
78
103
|
searchWeak(query: string, options: SearchOptions): SearchHit[];
|
|
104
|
+
/**
|
|
105
|
+
* @brief Builds the hit of one node, standing for itself only.
|
|
106
|
+
*
|
|
107
|
+
* @param node - The node the hit returns.
|
|
108
|
+
* @param member - The member of it that matched, or `null` when the node matched itself.
|
|
109
|
+
* @param match - How it matched.
|
|
110
|
+
* @param score - Its score by meaning, or `null` for a match by words.
|
|
111
|
+
* @returns The hit, without duplicates.
|
|
112
|
+
* @throws {Error} When the node is in no section, which a bundle never allows.
|
|
113
|
+
*/
|
|
114
|
+
private hitOf;
|
|
79
115
|
/**
|
|
80
116
|
* @brief Lists pages and entries in display order.
|
|
81
117
|
*
|
|
@@ -92,6 +128,21 @@ export declare class Retriever {
|
|
|
92
128
|
* @returns The node, the candidates when several fit, or `missing`.
|
|
93
129
|
*/
|
|
94
130
|
resolve(text: string, filter: NodeFilter): Resolution;
|
|
131
|
+
/**
|
|
132
|
+
* @brief Finds the names closest to a name that fits no node, for a caller who mistyped it.
|
|
133
|
+
*
|
|
134
|
+
* @param text - The name that fit no node.
|
|
135
|
+
* @param filter - Narrows the nodes that count, as for `resolve`.
|
|
136
|
+
* @returns Up to three names, the closest first. Empty when none is close.
|
|
137
|
+
*/
|
|
138
|
+
suggest(text: string, filter: NodeFilter): string[];
|
|
139
|
+
/**
|
|
140
|
+
* @brief Names a parameter, field, operation or definition that a name or a search matched.
|
|
141
|
+
*
|
|
142
|
+
* @param member - The member node.
|
|
143
|
+
* @returns Its kind and name.
|
|
144
|
+
*/
|
|
145
|
+
memberOf(member: NodeRef): MemberMatch;
|
|
95
146
|
/**
|
|
96
147
|
* @brief Describes a node in one row.
|
|
97
148
|
*
|
|
@@ -107,13 +158,30 @@ export declare class Retriever {
|
|
|
107
158
|
*/
|
|
108
159
|
describe(node: NodeRef): NodeReport;
|
|
109
160
|
/**
|
|
110
|
-
* @brief
|
|
161
|
+
* @brief Follows the edges of a node for some hops in each direction, the closest first.
|
|
111
162
|
*
|
|
112
163
|
* @param node - A page or an entry.
|
|
113
|
-
* @param options -
|
|
114
|
-
* @returns What the node links to and what links to it.
|
|
164
|
+
* @param options - Direction, edge kinds, depth and the most references to list.
|
|
165
|
+
* @returns What the node links to and what links to it, each with its next hop, and how many the limit left out.
|
|
166
|
+
*/
|
|
167
|
+
walk(node: NodeRef, options: WalkOptions): Walk;
|
|
168
|
+
/**
|
|
169
|
+
* @brief Finds the file a node is in.
|
|
170
|
+
*
|
|
171
|
+
* @param node - Any node.
|
|
172
|
+
* @returns The node itself when it is a file, else its closest file ancestor, else the node.
|
|
173
|
+
*/
|
|
174
|
+
fileOf(node: NodeRef): NodeRef;
|
|
175
|
+
/**
|
|
176
|
+
* @brief Finds the shortest chain of edges from one node to another, following edges the way they point.
|
|
177
|
+
*
|
|
178
|
+
* @param from - The node the chain starts at.
|
|
179
|
+
* @param to - The node the chain ends at.
|
|
180
|
+
* @param kinds - Edge kinds to follow. Empty follows every kind but `mentions`, unless `includeMentions` is set.
|
|
181
|
+
* @param includeMentions - Whether an empty `kinds` follows `mentions` too.
|
|
182
|
+
* @returns Each reference of the chain in order, or `null` when no chain leads from `from` to `to`.
|
|
115
183
|
*/
|
|
116
|
-
|
|
184
|
+
path(from: NodeRef, to: NodeRef, kinds: readonly EdgeKind[], includeMentions?: boolean): Reference[] | null;
|
|
117
185
|
/**
|
|
118
186
|
* @brief Exports one level of the bundle as nodes and edges.
|
|
119
187
|
*
|
|
@@ -17,6 +17,14 @@ export declare function nodeId(graph: Graph, node: NodeRef): string;
|
|
|
17
17
|
* @returns The id without the file, `#/` or slashes around it, with percent escapes decoded.
|
|
18
18
|
*/
|
|
19
19
|
export declare function normalizeId(text: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* @brief Finds the path on disk that belongs to a node.
|
|
22
|
+
*
|
|
23
|
+
* @param graph - Graph the node belongs to.
|
|
24
|
+
* @param node - The node to look up.
|
|
25
|
+
* @returns The path of the node itself, else of the file it is in. `null` for a section or a folder.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pathOf(graph: Graph, node: NodeRef): string | null;
|
|
20
28
|
/**
|
|
21
29
|
* @brief Describes a node in one row: what a search hit, a list row and a reference show.
|
|
22
30
|
*
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type EdgeKind, type NodeRef } from '../model';
|
|
2
|
+
import type { Graph } from '../query';
|
|
3
|
+
import type { Reference } from './report';
|
|
4
|
+
/** Most references a walk lists without a limit. */
|
|
5
|
+
export declare const DEFAULT_WALK_LIMIT = 50;
|
|
6
|
+
/** Levels a walk can follow links at: between pages and entries, or between the files that hold them. */
|
|
7
|
+
export declare const WALK_LEVELS: readonly ['entries', 'files'];
|
|
8
|
+
/** A level a walk follows links at. */
|
|
9
|
+
export type WalkLevel = (typeof WALK_LEVELS)[number];
|
|
10
|
+
/**
|
|
11
|
+
* @brief How far a walk of the references of a node goes.
|
|
12
|
+
*
|
|
13
|
+
* @property direction - `in` for what links to the node, `out` for what it links to, `both` for either.
|
|
14
|
+
* @property kinds - Edge kinds to follow. Empty follows every kind.
|
|
15
|
+
* @property depth - Hops to follow from the node. 1 lists its own references.
|
|
16
|
+
* @property limit - Most references to list, both directions and every hop together.
|
|
17
|
+
* @property level - `entries` follows the stored links. `files` follows them between the files that hold their
|
|
18
|
+
* ends, as the file level of the graph page draws them, and starts at the file of the node.
|
|
19
|
+
*/
|
|
20
|
+
export interface WalkOptions {
|
|
21
|
+
readonly direction: 'in' | 'out' | 'both';
|
|
22
|
+
readonly kinds: readonly EdgeKind[];
|
|
23
|
+
readonly depth: number;
|
|
24
|
+
readonly limit: number;
|
|
25
|
+
readonly level: WalkLevel;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @brief A reference with the references of its node one hop further, in the same direction.
|
|
29
|
+
*
|
|
30
|
+
* @property next - What the node of this reference links to, or what links to it, on the next hop. Empty on the
|
|
31
|
+
* last hop, for a node listed under another reference already, and for a node the limit cut off.
|
|
32
|
+
*/
|
|
33
|
+
export interface WalkReference extends Reference {
|
|
34
|
+
readonly next: readonly WalkReference[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @brief The references of a node, followed for some hops in each direction.
|
|
38
|
+
*
|
|
39
|
+
* @property linksTo - What the node links to, each with what that links to on the next hop.
|
|
40
|
+
* @property linkedFrom - What links to the node, each with what links to that on the next hop.
|
|
41
|
+
* @property omitted - References the walk reached within its depth but did not list, because of its limit.
|
|
42
|
+
*/
|
|
43
|
+
export interface Walk {
|
|
44
|
+
readonly linksTo: readonly WalkReference[];
|
|
45
|
+
readonly linkedFrom: readonly WalkReference[];
|
|
46
|
+
readonly omitted: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @brief Follows the references of a node for some hops, breadth first, so the closest references are listed
|
|
50
|
+
* before the limit cuts the rest.
|
|
51
|
+
*
|
|
52
|
+
* Each hop takes its steps from both directions in turn, so neither direction uses up the limit alone. A node is
|
|
53
|
+
* listed once per direction: under the first reference that reaches it, with every relation that reference's node
|
|
54
|
+
* has to it. The start node is never listed again. Past the limit the walk goes on to its depth without listing,
|
|
55
|
+
* so it counts every reference it leaves out.
|
|
56
|
+
*
|
|
57
|
+
* @param graph - Graph the node belongs to.
|
|
58
|
+
* @param start - The node the walk starts at.
|
|
59
|
+
* @param options - Direction, edge kinds, depth and limit.
|
|
60
|
+
* @returns Both directions of the walk, and how many references the limit left out.
|
|
61
|
+
*/
|
|
62
|
+
export declare function walkReferences(graph: Graph, start: NodeRef, options: WalkOptions): Walk;
|
|
63
|
+
/**
|
|
64
|
+
* @brief Finds the shortest chain of edges from one node to another, following edges the way they point.
|
|
65
|
+
*
|
|
66
|
+
* Of the chains that are equally short, the one with the fewest `mentions` steps wins, so a link a description makes
|
|
67
|
+
* only stands in for code where code offers no chain as short.
|
|
68
|
+
*
|
|
69
|
+
* @param graph - Graph both nodes belong to.
|
|
70
|
+
* @param from - The node the chain starts at.
|
|
71
|
+
* @param to - The node the chain ends at.
|
|
72
|
+
* @param kinds - Edge kinds to follow. Empty follows every kind but `mentions`, unless `includeMentions` is set.
|
|
73
|
+
* @param includeMentions - Whether an empty `kinds` follows `mentions` too.
|
|
74
|
+
* @returns The references from `from` to `to`, in order, each to the next node of the chain. Empty when `from` is
|
|
75
|
+
* `to`. `null` when no chain leads there.
|
|
76
|
+
*/
|
|
77
|
+
export declare function shortestPath(graph: Graph, from: NodeRef, to: NodeRef, kinds: readonly EdgeKind[], includeMentions?: boolean): Reference[] | null;
|