@g3nomaly/analyze 0.0.0-stage → 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/LICENSE +95 -0
- package/README.md +76 -2
- package/dist/THIRD_PARTY_LICENSES.txt +1904 -0
- package/dist/api/bundle-builder.d.ts +94 -0
- package/dist/api/bundle-cache.d.ts +73 -0
- package/dist/api/bundle-loader.d.ts +65 -0
- package/dist/api/create-docs.d.ts +91 -0
- package/dist/api/embedding.d.ts +41 -0
- package/dist/api/errors.d.ts +35 -0
- package/dist/api/list.d.ts +106 -0
- package/dist/api/options.d.ts +74 -0
- package/dist/api/refs.d.ts +136 -0
- package/dist/api/scan.d.ts +56 -0
- package/dist/api/search.d.ts +132 -0
- package/dist/api/services.d.ts +15 -0
- package/dist/api/show.d.ts +100 -0
- package/dist/api/site-reader.d.ts +19 -0
- package/dist/api/site-writer.d.ts +43 -0
- package/dist/api/source.d.ts +57 -0
- package/dist/api/target.d.ts +12 -0
- package/dist/api/template.d.ts +5 -0
- package/dist/assets/tree-sitter-c-sharp.wasm +0 -0
- package/dist/assets/tree-sitter-c.wasm +0 -0
- package/dist/assets/tree-sitter-cpp.wasm +0 -0
- package/dist/assets/tree-sitter-go.wasm +0 -0
- package/dist/assets/tree-sitter-java.wasm +0 -0
- package/dist/assets/tree-sitter-javascript.wasm +0 -0
- package/dist/assets/tree-sitter-kotlin.wasm +0 -0
- package/dist/assets/tree-sitter-php.wasm +0 -0
- package/dist/assets/tree-sitter-python.wasm +0 -0
- package/dist/assets/tree-sitter-ruby.wasm +0 -0
- package/dist/assets/tree-sitter-rust.wasm +0 -0
- package/dist/assets/tree-sitter-scala.wasm +0 -0
- package/dist/assets/tree-sitter-tsx.wasm +0 -0
- package/dist/assets/tree-sitter-typescript.wasm +0 -0
- package/dist/assets/vectors.bin +0 -0
- package/dist/assets/vocab.txt +33731 -0
- package/dist/cli.js +9317 -0
- package/dist/embeddings/abbreviations.d.ts +7 -0
- package/dist/embeddings/index-builder.d.ts +12 -0
- package/dist/embeddings/index.d.ts +10 -0
- package/dist/embeddings/model.d.ts +126 -0
- package/dist/embeddings/searcher.d.ts +84 -0
- package/dist/embeddings/vectors.d.ts +77 -0
- package/dist/embeddings/words.d.ts +46 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8747 -0
- package/dist/model/index.d.ts +788 -0
- package/dist/model/registry.d.ts +687 -0
- package/dist/query/graph.d.ts +123 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/name-search.d.ts +65 -0
- package/dist/query/semantic.d.ts +38 -0
- package/dist/query/text.d.ts +22 -0
- package/dist/retrieval/describe.d.ts +33 -0
- package/dist/retrieval/filter.d.ts +36 -0
- package/dist/retrieval/index.d.ts +7 -0
- package/dist/retrieval/markdown.d.ts +17 -0
- package/dist/retrieval/report.d.ts +291 -0
- package/dist/retrieval/resolve.d.ts +31 -0
- package/dist/retrieval/retriever.d.ts +105 -0
- package/dist/retrieval/summary.d.ts +27 -0
- package/dist/scanner/code/doc/clean.d.ts +36 -0
- package/dist/scanner/code/doc/index.d.ts +12 -0
- package/dist/scanner/code/doc/markdown.d.ts +8 -0
- package/dist/scanner/code/doc/python.d.ts +8 -0
- package/dist/scanner/code/doc/tagged.d.ts +19 -0
- package/dist/scanner/code/doc/types.d.ts +33 -0
- package/dist/scanner/code/doc/xml.d.ts +8 -0
- package/dist/scanner/code/example.d.ts +57 -0
- package/dist/scanner/code/extract.d.ts +113 -0
- package/dist/scanner/code/grammar.d.ts +44 -0
- package/dist/scanner/code/language.d.ts +183 -0
- package/dist/scanner/code/languages/c-family.d.ts +5 -0
- package/dist/scanner/code/languages/csharp.d.ts +3 -0
- package/dist/scanner/code/languages/ecmascript.d.ts +7 -0
- package/dist/scanner/code/languages/go.d.ts +3 -0
- package/dist/scanner/code/languages/index.d.ts +33 -0
- package/dist/scanner/code/languages/java.d.ts +3 -0
- package/dist/scanner/code/languages/kotlin.d.ts +3 -0
- package/dist/scanner/code/languages/php.d.ts +3 -0
- package/dist/scanner/code/languages/python.d.ts +3 -0
- package/dist/scanner/code/languages/ruby.d.ts +3 -0
- package/dist/scanner/code/languages/rust.d.ts +3 -0
- package/dist/scanner/code/languages/scala.d.ts +3 -0
- package/dist/scanner/code/languages/shared.d.ts +36 -0
- package/dist/scanner/code/planner.d.ts +107 -0
- package/dist/scanner/code/symbols.d.ts +134 -0
- package/dist/scanner/code/types.d.ts +126 -0
- package/dist/scanner/config.d.ts +42 -0
- package/dist/scanner/content.d.ts +73 -0
- package/dist/scanner/decisions/parse.d.ts +37 -0
- package/dist/scanner/decisions/planner.d.ts +42 -0
- package/dist/scanner/docs.d.ts +69 -0
- package/dist/scanner/files.d.ts +85 -0
- package/dist/scanner/glossary/parse.d.ts +40 -0
- package/dist/scanner/glossary/planner.d.ts +49 -0
- package/dist/scanner/glossary/terms.d.ts +116 -0
- package/dist/scanner/graph/builder.d.ts +114 -0
- package/dist/scanner/highlight.d.ts +54 -0
- package/dist/scanner/ignore.d.ts +25 -0
- package/dist/scanner/index.d.ts +43 -0
- package/dist/scanner/markdown/frontmatter.d.ts +24 -0
- package/dist/scanner/markdown/links.d.ts +60 -0
- package/dist/scanner/markdown/outline.d.ts +35 -0
- package/dist/scanner/markdown/renderer.d.ts +63 -0
- package/dist/scanner/openapi/planner.d.ts +96 -0
- package/dist/scanner/packages.d.ts +28 -0
- package/dist/scanner/reporter.d.ts +10 -0
- package/dist/scanner/scanner.d.ts +66 -0
- package/dist/scanner/schema/definitions.d.ts +79 -0
- package/dist/scanner/schema/describe.d.ts +105 -0
- package/dist/scanner/schema/planner.d.ts +49 -0
- package/dist/scanner/schema/registry.d.ts +68 -0
- package/dist/scanner/skills/classify.d.ts +21 -0
- package/dist/scanner/skills/layout.d.ts +46 -0
- package/dist/scanner/skills/planner.d.ts +61 -0
- package/dist/scanner/specs.d.ts +56 -0
- package/dist/scanner/sql/catalog.d.ts +98 -0
- package/dist/scanner/sql/cursor.d.ts +112 -0
- package/dist/scanner/sql/database.d.ts +51 -0
- package/dist/scanner/sql/parse.d.ts +122 -0
- package/dist/scanner/sql/planner.d.ts +69 -0
- package/dist/scanner/sql/query.d.ts +73 -0
- package/dist/scanner/sql/registry.d.ts +63 -0
- package/dist/scanner/sql/source.d.ts +10 -0
- package/dist/scanner/sql/statements.d.ts +42 -0
- package/dist/scanner/sql/tokens.d.ts +51 -0
- package/dist/scanner/tasks/layout.d.ts +52 -0
- package/dist/scanner/tasks/planner.d.ts +130 -0
- package/dist/scanner/tasks/schema.d.ts +88 -0
- package/dist/scanner/text.d.ts +14 -0
- package/package.json +104 -4
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { NodeFilter, NodeSummary, ReferenceOptions, References, Retriever } from '../retrieval';
|
|
3
|
+
/**
|
|
4
|
+
* Schema of the `refs` options.
|
|
5
|
+
*
|
|
6
|
+
* @property target - Id, path or name of the node.
|
|
7
|
+
* @property incoming - Only what links to the node.
|
|
8
|
+
* @property outgoing - Only what the node links to.
|
|
9
|
+
* @property edges - Only edges of these kinds. Empty or absent keeps every kind.
|
|
10
|
+
*/
|
|
11
|
+
declare const refsSchema: z.ZodPipe<z.ZodObject<{
|
|
12
|
+
onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
|
|
13
|
+
kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
14
|
+
class: "class";
|
|
15
|
+
decision: "decision";
|
|
16
|
+
definition: "definition";
|
|
17
|
+
enum: "enum";
|
|
18
|
+
field: "field";
|
|
19
|
+
file: "file";
|
|
20
|
+
folder: "folder";
|
|
21
|
+
function: "function";
|
|
22
|
+
interface: "interface";
|
|
23
|
+
namespace: "namespace";
|
|
24
|
+
operation: "operation";
|
|
25
|
+
package: "package";
|
|
26
|
+
parameter: "parameter";
|
|
27
|
+
phase: "phase";
|
|
28
|
+
plan: "plan";
|
|
29
|
+
query: "query";
|
|
30
|
+
struct: "struct";
|
|
31
|
+
table: "table";
|
|
32
|
+
task: "task";
|
|
33
|
+
term: "term";
|
|
34
|
+
trait: "trait";
|
|
35
|
+
type: "type";
|
|
36
|
+
}>>>>;
|
|
37
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
code: "code";
|
|
39
|
+
database: "database";
|
|
40
|
+
docs: "docs";
|
|
41
|
+
skills: "skills";
|
|
42
|
+
tasks: "tasks";
|
|
43
|
+
}>>;
|
|
44
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
45
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
46
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
47
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
48
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
from: z.ZodOptional<z.ZodString>;
|
|
50
|
+
cache: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
target: z.ZodString;
|
|
52
|
+
incoming: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
outgoing: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
edges: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
55
|
+
affects: "affects";
|
|
56
|
+
depends: "depends";
|
|
57
|
+
extends: "extends";
|
|
58
|
+
mentions: "mentions";
|
|
59
|
+
names: "names";
|
|
60
|
+
reads: "reads";
|
|
61
|
+
references: "references";
|
|
62
|
+
returns: "returns";
|
|
63
|
+
throws: "throws";
|
|
64
|
+
type: "type";
|
|
65
|
+
uses: "uses";
|
|
66
|
+
writes: "writes";
|
|
67
|
+
}>>>>;
|
|
68
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
69
|
+
source: import("./source").BundleSource;
|
|
70
|
+
reporter: import("../scanner").Reporter;
|
|
71
|
+
request: {
|
|
72
|
+
target: string;
|
|
73
|
+
filter: NodeFilter;
|
|
74
|
+
references: {
|
|
75
|
+
direction: "both" | "in" | "out";
|
|
76
|
+
kinds: readonly ("affects" | "depends" | "extends" | "mentions" | "names" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}, {
|
|
80
|
+
onWarning?: import("./options").WarningHandler | undefined;
|
|
81
|
+
kinds?: readonly ("class" | "decision" | "definition" | "enum" | "field" | "file" | "folder" | "function" | "interface" | "namespace" | "operation" | "package" | "parameter" | "phase" | "plan" | "query" | "struct" | "table" | "task" | "term" | "trait" | "type")[] | undefined;
|
|
82
|
+
section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
|
|
83
|
+
repo?: string | undefined;
|
|
84
|
+
skillDirs?: readonly string[] | undefined;
|
|
85
|
+
docDirs?: readonly string[] | undefined;
|
|
86
|
+
excludes?: readonly string[] | undefined;
|
|
87
|
+
embeddings?: boolean | undefined;
|
|
88
|
+
from?: string | undefined;
|
|
89
|
+
cache?: boolean | undefined;
|
|
90
|
+
target: string;
|
|
91
|
+
incoming?: boolean | undefined;
|
|
92
|
+
outgoing?: boolean | undefined;
|
|
93
|
+
edges?: readonly ("affects" | "depends" | "extends" | "mentions" | "names" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[] | undefined;
|
|
94
|
+
}>>;
|
|
95
|
+
/** Options of `refs`: the node, which links to follow, and the bundle to read. */
|
|
96
|
+
export type RefsOptions = z.input<typeof refsSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* One `refs` on a loaded bundle.
|
|
99
|
+
*
|
|
100
|
+
* @property target - Id, path or name of the node.
|
|
101
|
+
* @property filter - Narrows a name to one node.
|
|
102
|
+
* @property references - Which links to keep: direction and edge kinds.
|
|
103
|
+
*/
|
|
104
|
+
export interface RefsRequest {
|
|
105
|
+
readonly target: string;
|
|
106
|
+
readonly filter: NodeFilter;
|
|
107
|
+
readonly references: ReferenceOptions;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* What `refs` finds. The CLI prints it with `refs --json`.
|
|
111
|
+
*
|
|
112
|
+
* @property node - The node the references are of.
|
|
113
|
+
*/
|
|
114
|
+
export interface RefsResult extends References {
|
|
115
|
+
readonly node: NodeSummary;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Lists the references of one node of a loaded bundle.
|
|
119
|
+
*
|
|
120
|
+
* @param retriever - The loaded bundle to read.
|
|
121
|
+
* @param request - The node, the filter that narrows a name, and the references to keep.
|
|
122
|
+
* @returns The node with what it links to and what links to it.
|
|
123
|
+
* @throws {QueryError} When no node fits the target, or several do.
|
|
124
|
+
*/
|
|
125
|
+
export declare function refsIn(retriever: Retriever, request: RefsRequest): RefsResult;
|
|
126
|
+
/**
|
|
127
|
+
* Lists what a node links to and what links to it.
|
|
128
|
+
*
|
|
129
|
+
* @param options - The node, which links to follow, and the repository or site to read.
|
|
130
|
+
* @returns The node with its references.
|
|
131
|
+
* @throws {OptionsError} When the options are not valid.
|
|
132
|
+
* @throws {SourceError} When the repository or the site cannot be read.
|
|
133
|
+
* @throws {QueryError} When no node fits the target, or several do.
|
|
134
|
+
*/
|
|
135
|
+
export declare function refs(options: RefsOptions): Promise<RefsResult>;
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What decides the content of a scan.
|
|
4
|
+
*
|
|
5
|
+
* @property repo - Absolute path of the repository to document.
|
|
6
|
+
* @property skillDirs - Absolute skill directories. Empty means: find every `SKILL.md` in the repository.
|
|
7
|
+
* @property docDirs - Absolute docs directories. Empty means: every markdown, JSON and YAML file in the repository.
|
|
8
|
+
* @property excludes - Glob patterns of paths to skip.
|
|
9
|
+
* @property embeddings - Whether the bundle gets the embedding model and search by meaning.
|
|
10
|
+
*/
|
|
11
|
+
export interface ScanOptions {
|
|
12
|
+
readonly repo: string;
|
|
13
|
+
readonly skillDirs: readonly string[];
|
|
14
|
+
readonly docDirs: readonly string[];
|
|
15
|
+
readonly excludes: readonly string[];
|
|
16
|
+
readonly embeddings: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options that choose what to scan, as a caller passes them. Relative paths resolve against the working directory.
|
|
20
|
+
*
|
|
21
|
+
* @property repo - Repository to read. Default: the working directory.
|
|
22
|
+
* @property skillDirs - Read skills from these directories instead of the repository.
|
|
23
|
+
* @property docDirs - Read docs from these directories instead of the repository.
|
|
24
|
+
* @property excludes - Glob patterns of paths to skip, such as `src/legacy/**`.
|
|
25
|
+
* @property embeddings - `false` leaves out search by meaning. Default: `true`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const scanShape: {
|
|
28
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
29
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
30
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
31
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
32
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
};
|
|
34
|
+
/** The scan options after validation, before defaults. */
|
|
35
|
+
export type ScanFields = z.output<z.ZodObject<typeof scanShape>>;
|
|
36
|
+
/**
|
|
37
|
+
* Fills in the defaults of validated scan options and makes their paths absolute against the working directory.
|
|
38
|
+
*
|
|
39
|
+
* @param fields - Validated scan options.
|
|
40
|
+
* @returns The scan options, with defaults filled in.
|
|
41
|
+
*/
|
|
42
|
+
export declare function scanOf(fields: ScanFields): ScanOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Names the site file of a repository. `createDocs` writes it, and nothing else outside the cache.
|
|
45
|
+
*
|
|
46
|
+
* @param repo - Absolute path of the repository.
|
|
47
|
+
* @returns `<repo>/analyze_out/index.html`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function siteFileOf(repo: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Names the directory where the retrieval functions keep the scans of a repository.
|
|
52
|
+
*
|
|
53
|
+
* @param repo - Absolute path of the repository.
|
|
54
|
+
* @returns `<repo>/analyze_out/cache`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function cacheDirOf(repo: string): string;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type NodeFilter, type Retriever, type SearchHit, type SearchMode } from '../retrieval';
|
|
3
|
+
/** Most hits of a search without a limit. */
|
|
4
|
+
export declare const DEFAULT_SEARCH_LIMIT = 10;
|
|
5
|
+
/**
|
|
6
|
+
* Schema of the `search` options.
|
|
7
|
+
*
|
|
8
|
+
* @property query - Words to find.
|
|
9
|
+
* @property by - `name` searches by words, `meaning` by the embedding model, `both` by both. Default: `both`.
|
|
10
|
+
* @property limit - Most hits. Default: 10.
|
|
11
|
+
*/
|
|
12
|
+
declare const searchSchema: z.ZodPipe<z.ZodObject<{
|
|
13
|
+
onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
|
|
14
|
+
kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
15
|
+
class: "class";
|
|
16
|
+
decision: "decision";
|
|
17
|
+
definition: "definition";
|
|
18
|
+
enum: "enum";
|
|
19
|
+
field: "field";
|
|
20
|
+
file: "file";
|
|
21
|
+
folder: "folder";
|
|
22
|
+
function: "function";
|
|
23
|
+
interface: "interface";
|
|
24
|
+
namespace: "namespace";
|
|
25
|
+
operation: "operation";
|
|
26
|
+
package: "package";
|
|
27
|
+
parameter: "parameter";
|
|
28
|
+
phase: "phase";
|
|
29
|
+
plan: "plan";
|
|
30
|
+
query: "query";
|
|
31
|
+
struct: "struct";
|
|
32
|
+
table: "table";
|
|
33
|
+
task: "task";
|
|
34
|
+
term: "term";
|
|
35
|
+
trait: "trait";
|
|
36
|
+
type: "type";
|
|
37
|
+
}>>>>;
|
|
38
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
39
|
+
code: "code";
|
|
40
|
+
database: "database";
|
|
41
|
+
docs: "docs";
|
|
42
|
+
skills: "skills";
|
|
43
|
+
tasks: "tasks";
|
|
44
|
+
}>>;
|
|
45
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
46
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
47
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
48
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
49
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
from: z.ZodOptional<z.ZodString>;
|
|
51
|
+
cache: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
query: z.ZodString;
|
|
53
|
+
by: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
both: "both";
|
|
55
|
+
meaning: "meaning";
|
|
56
|
+
name: "name";
|
|
57
|
+
}>>;
|
|
58
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
60
|
+
source: import("./source").BundleSource;
|
|
61
|
+
reporter: import("../scanner").Reporter;
|
|
62
|
+
request: {
|
|
63
|
+
query: string;
|
|
64
|
+
mode: "both" | "meaning" | "name";
|
|
65
|
+
limit: number;
|
|
66
|
+
filter: NodeFilter;
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
onWarning?: import("./options").WarningHandler | undefined;
|
|
70
|
+
kinds?: readonly ("class" | "decision" | "definition" | "enum" | "field" | "file" | "folder" | "function" | "interface" | "namespace" | "operation" | "package" | "parameter" | "phase" | "plan" | "query" | "struct" | "table" | "task" | "term" | "trait" | "type")[] | undefined;
|
|
71
|
+
section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
|
|
72
|
+
repo?: string | undefined;
|
|
73
|
+
skillDirs?: readonly string[] | undefined;
|
|
74
|
+
docDirs?: readonly string[] | undefined;
|
|
75
|
+
excludes?: readonly string[] | undefined;
|
|
76
|
+
embeddings?: boolean | undefined;
|
|
77
|
+
from?: string | undefined;
|
|
78
|
+
cache?: boolean | undefined;
|
|
79
|
+
query: string;
|
|
80
|
+
by?: "both" | "meaning" | "name" | undefined;
|
|
81
|
+
limit?: number | undefined;
|
|
82
|
+
}>>;
|
|
83
|
+
/** Options of `search`: the words, how to match them, and the bundle to search. */
|
|
84
|
+
export type SearchOptions = z.input<typeof searchSchema>;
|
|
85
|
+
/**
|
|
86
|
+
* One search on a loaded bundle.
|
|
87
|
+
*
|
|
88
|
+
* @property query - The words to find.
|
|
89
|
+
* @property mode - How to match them: by words, by meaning, or both.
|
|
90
|
+
* @property limit - Most hits.
|
|
91
|
+
* @property filter - Narrows the nodes that count.
|
|
92
|
+
*/
|
|
93
|
+
export interface SearchRequest {
|
|
94
|
+
readonly query: string;
|
|
95
|
+
readonly mode: SearchMode;
|
|
96
|
+
readonly limit: number;
|
|
97
|
+
readonly filter: NodeFilter;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* What `search` finds. The CLI prints it with `search --json`.
|
|
101
|
+
*
|
|
102
|
+
* @property query - The words searched for.
|
|
103
|
+
* @property mode - How the words were matched.
|
|
104
|
+
* @property model - Name of the embedding model of the bundle. `null` when the bundle has none.
|
|
105
|
+
* @property hits - Hits, best first.
|
|
106
|
+
*/
|
|
107
|
+
export interface SearchResult {
|
|
108
|
+
readonly query: string;
|
|
109
|
+
readonly mode: SearchMode;
|
|
110
|
+
readonly model: string | null;
|
|
111
|
+
readonly hits: readonly SearchHit[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Searches a loaded bundle.
|
|
115
|
+
*
|
|
116
|
+
* @param retriever - The loaded bundle to search.
|
|
117
|
+
* @param request - The words, the mode, the limit and the filter.
|
|
118
|
+
* @returns The hits, best first.
|
|
119
|
+
* @throws {QueryError} When the search is by meaning and the bundle has no embeddings.
|
|
120
|
+
*/
|
|
121
|
+
export declare function searchIn(retriever: Retriever, request: SearchRequest): SearchResult;
|
|
122
|
+
/**
|
|
123
|
+
* Finds pages and entries by their words and by meaning.
|
|
124
|
+
*
|
|
125
|
+
* @param options - The words, how to match them, and the repository or site to search.
|
|
126
|
+
* @returns The hits, best first.
|
|
127
|
+
* @throws {OptionsError} When the options are not valid.
|
|
128
|
+
* @throws {SourceError} When the repository or the site cannot be read.
|
|
129
|
+
* @throws {QueryError} When the search is by meaning and the bundle has no embeddings.
|
|
130
|
+
*/
|
|
131
|
+
export declare function search(options: SearchOptions): Promise<SearchResult>;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Reporter } from '../scanner';
|
|
2
|
+
import { BundleBuilder } from './bundle-builder';
|
|
3
|
+
import type { ScanOptions } from './scan';
|
|
4
|
+
/** Name and version of the tool, recorded in every bundle it builds. */
|
|
5
|
+
export declare const GENERATOR: string;
|
|
6
|
+
/**
|
|
7
|
+
* @brief Wires the services that scan one repository into a builder.
|
|
8
|
+
*
|
|
9
|
+
* Reads the `.analyzeignore` of the repository, creating it when absent, and skips its patterns and `scan.excludes`.
|
|
10
|
+
*
|
|
11
|
+
* @param scan - What to scan. Its `embeddings` flag decides whether the builder embeds the nodes.
|
|
12
|
+
* @param reporter - Receives the warnings of the scan.
|
|
13
|
+
* @returns A builder for that scan.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createBuilder(scan: ScanOptions, reporter: Reporter): BundleBuilder;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { NodeFilter, NodeReport, Retriever } from '../retrieval';
|
|
3
|
+
/**
|
|
4
|
+
* Schema of the `show` options.
|
|
5
|
+
*
|
|
6
|
+
* @property target - Id, path or name of the node.
|
|
7
|
+
*/
|
|
8
|
+
declare const showSchema: z.ZodPipe<z.ZodObject<{
|
|
9
|
+
onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
|
|
10
|
+
kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
11
|
+
class: "class";
|
|
12
|
+
decision: "decision";
|
|
13
|
+
definition: "definition";
|
|
14
|
+
enum: "enum";
|
|
15
|
+
field: "field";
|
|
16
|
+
file: "file";
|
|
17
|
+
folder: "folder";
|
|
18
|
+
function: "function";
|
|
19
|
+
interface: "interface";
|
|
20
|
+
namespace: "namespace";
|
|
21
|
+
operation: "operation";
|
|
22
|
+
package: "package";
|
|
23
|
+
parameter: "parameter";
|
|
24
|
+
phase: "phase";
|
|
25
|
+
plan: "plan";
|
|
26
|
+
query: "query";
|
|
27
|
+
struct: "struct";
|
|
28
|
+
table: "table";
|
|
29
|
+
task: "task";
|
|
30
|
+
term: "term";
|
|
31
|
+
trait: "trait";
|
|
32
|
+
type: "type";
|
|
33
|
+
}>>>>;
|
|
34
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
code: "code";
|
|
36
|
+
database: "database";
|
|
37
|
+
docs: "docs";
|
|
38
|
+
skills: "skills";
|
|
39
|
+
tasks: "tasks";
|
|
40
|
+
}>>;
|
|
41
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
42
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
43
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
44
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
45
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
from: z.ZodOptional<z.ZodString>;
|
|
47
|
+
cache: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
target: z.ZodString;
|
|
49
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
50
|
+
source: import("./source").BundleSource;
|
|
51
|
+
reporter: import("../scanner").Reporter;
|
|
52
|
+
request: {
|
|
53
|
+
target: string;
|
|
54
|
+
filter: NodeFilter;
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
onWarning?: import("./options").WarningHandler | undefined;
|
|
58
|
+
kinds?: readonly ("class" | "decision" | "definition" | "enum" | "field" | "file" | "folder" | "function" | "interface" | "namespace" | "operation" | "package" | "parameter" | "phase" | "plan" | "query" | "struct" | "table" | "task" | "term" | "trait" | "type")[] | undefined;
|
|
59
|
+
section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
|
|
60
|
+
repo?: string | undefined;
|
|
61
|
+
skillDirs?: readonly string[] | undefined;
|
|
62
|
+
docDirs?: readonly string[] | undefined;
|
|
63
|
+
excludes?: readonly string[] | undefined;
|
|
64
|
+
embeddings?: boolean | undefined;
|
|
65
|
+
from?: string | undefined;
|
|
66
|
+
cache?: boolean | undefined;
|
|
67
|
+
target: string;
|
|
68
|
+
}>>;
|
|
69
|
+
/** Options of `show`: the node, and the bundle to read it from. */
|
|
70
|
+
export type ShowOptions = z.input<typeof showSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* One `show` on a loaded bundle.
|
|
73
|
+
*
|
|
74
|
+
* @property target - Id, path or name of the node.
|
|
75
|
+
* @property filter - Narrows a name to one node.
|
|
76
|
+
*/
|
|
77
|
+
export interface ShowRequest {
|
|
78
|
+
readonly target: string;
|
|
79
|
+
readonly filter: NodeFilter;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Describes one node of a loaded bundle.
|
|
83
|
+
*
|
|
84
|
+
* @param retriever - The loaded bundle to read.
|
|
85
|
+
* @param request - The node and the filter that narrows a name.
|
|
86
|
+
* @returns The report of the node: text, parameters, references.
|
|
87
|
+
* @throws {QueryError} When no node fits the target, or several do.
|
|
88
|
+
*/
|
|
89
|
+
export declare function showIn(retriever: Retriever, request: ShowRequest): NodeReport;
|
|
90
|
+
/**
|
|
91
|
+
* Describes one page or entry: text, parameters, references.
|
|
92
|
+
*
|
|
93
|
+
* @param options - The node, and the repository or site to read it from.
|
|
94
|
+
* @returns The report of the node. The CLI prints it with `show --json`.
|
|
95
|
+
* @throws {OptionsError} When the options are not valid.
|
|
96
|
+
* @throws {SourceError} When the repository or the site cannot be read.
|
|
97
|
+
* @throws {QueryError} When no node fits the target, or several do.
|
|
98
|
+
*/
|
|
99
|
+
export declare function show(options: ShowOptions): Promise<NodeReport>;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DocsBundle } from '../model';
|
|
2
|
+
/**
|
|
3
|
+
* Checks that parsed JSON has the parts of a bundle that queries read: `meta`, `nodes` and `edges`.
|
|
4
|
+
*
|
|
5
|
+
* @param value - Parsed JSON to check.
|
|
6
|
+
* @returns `true` when `value` has all three parts.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isBundle(value: unknown): value is DocsBundle;
|
|
9
|
+
/**
|
|
10
|
+
* @brief Reads the bundle back out of a site that `createDocs` wrote.
|
|
11
|
+
*
|
|
12
|
+
* The inverse of `HtmlSiteWriter.render`: parses the JSON in the data element of the site.
|
|
13
|
+
*
|
|
14
|
+
* @param html - Text of the site file.
|
|
15
|
+
* @param path - Path of the file, only for the error message.
|
|
16
|
+
* @returns The bundle the site holds.
|
|
17
|
+
* @throws {SourceError} When the file is no analyze site.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readSite(html: string, path: string): DocsBundle;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type DocsBundle } from '../model';
|
|
2
|
+
/** Writes a bundle as a documentation site. */
|
|
3
|
+
export interface SiteWriter {
|
|
4
|
+
/**
|
|
5
|
+
* Writes the site for `bundle` to `path`.
|
|
6
|
+
*
|
|
7
|
+
* @param path - Where to write the site file.
|
|
8
|
+
* @param bundle - The bundle the site shows.
|
|
9
|
+
* @returns Size of the written site in bytes.
|
|
10
|
+
*/
|
|
11
|
+
write(path: string, bundle: DocsBundle): Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @brief Fills the prebuilt single-file app with a bundle.
|
|
15
|
+
*
|
|
16
|
+
* Puts the title into `<title>` and the bundle as JSON into the data `<script>` element. Holds the template.
|
|
17
|
+
* `createDocs` creates one with `TEMPLATE_HTML` from `src/api/template.ts`; `readSite` reads the result back.
|
|
18
|
+
* Created with `new HtmlSiteWriter(TEMPLATE_HTML)`.
|
|
19
|
+
*/
|
|
20
|
+
export declare class HtmlSiteWriter implements SiteWriter {
|
|
21
|
+
private readonly template;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a writer for one template.
|
|
24
|
+
*
|
|
25
|
+
* @param template - Page text with the title and data placeholders, each exactly once.
|
|
26
|
+
*/
|
|
27
|
+
constructor(template: string);
|
|
28
|
+
/**
|
|
29
|
+
* Returns the template with the escaped title and the bundle as script-safe JSON in place of the placeholders.
|
|
30
|
+
*
|
|
31
|
+
* @param bundle - The bundle to put in the page.
|
|
32
|
+
* @returns The finished page text.
|
|
33
|
+
*/
|
|
34
|
+
render(bundle: DocsBundle): string;
|
|
35
|
+
/**
|
|
36
|
+
* Writes the rendered site to `path`, creating its directory.
|
|
37
|
+
*
|
|
38
|
+
* @param path - Where to write the site file.
|
|
39
|
+
* @param bundle - The bundle to render.
|
|
40
|
+
* @returns Size of the written site in bytes.
|
|
41
|
+
*/
|
|
42
|
+
write(path: string, bundle: DocsBundle): Promise<number>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Retriever } from '../retrieval';
|
|
3
|
+
import type { Reporter } from '../scanner';
|
|
4
|
+
import { type ScanOptions } from './scan';
|
|
5
|
+
/**
|
|
6
|
+
* Where a query gets its bundle: `site` is an HTML file that `createDocs` wrote; `scan` is a scan of the
|
|
7
|
+
* repository, whose result is kept in `analyze_out/cache` of the repository when `cache` is set.
|
|
8
|
+
*/
|
|
9
|
+
export type BundleSource = {
|
|
10
|
+
readonly kind: 'site';
|
|
11
|
+
readonly file: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'scan';
|
|
14
|
+
readonly scan: ScanOptions;
|
|
15
|
+
readonly cache: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The options that choose the bundle a query reads, as a caller passes them.
|
|
19
|
+
*
|
|
20
|
+
* @property from - An HTML file that `createDocs` wrote, read in place of the repository. Excludes the scan options.
|
|
21
|
+
* @property cache - `false` scans the repository again even when no file changed. Default: `true`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const sourceShape: {
|
|
24
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
25
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
26
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
27
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
28
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
from: z.ZodOptional<z.ZodString>;
|
|
30
|
+
cache: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
};
|
|
32
|
+
/** The source options after validation. */
|
|
33
|
+
type SourceFields = z.output<z.ZodObject<typeof sourceShape>>;
|
|
34
|
+
/**
|
|
35
|
+
* Adds an issue to the schema's refinement context for every scan option that comes with `from`.
|
|
36
|
+
*
|
|
37
|
+
* @param fields - Validated source options.
|
|
38
|
+
* @param context - Refinement context of the schema, which collects the issues.
|
|
39
|
+
*/
|
|
40
|
+
export declare function checkSource(fields: SourceFields, context: z.RefinementCtx): void;
|
|
41
|
+
/**
|
|
42
|
+
* Turns validated source options into a bundle source.
|
|
43
|
+
*
|
|
44
|
+
* @param fields - Validated source options, checked by `checkSource` first.
|
|
45
|
+
* @returns The site file to read, with an absolute path, or the scan to run.
|
|
46
|
+
*/
|
|
47
|
+
export declare function sourceOf(fields: SourceFields): BundleSource;
|
|
48
|
+
/**
|
|
49
|
+
* Loads the bundle of a source and opens it for queries, handing warnings of the load to `reporter`.
|
|
50
|
+
*
|
|
51
|
+
* @param source - Where the bundle comes from.
|
|
52
|
+
* @param reporter - Receives the warnings of the load.
|
|
53
|
+
* @returns The retriever that answers queries on the bundle.
|
|
54
|
+
* @throws {SourceError} When the site file or the repository cannot be read.
|
|
55
|
+
*/
|
|
56
|
+
export declare function openRetriever(source: BundleSource, reporter: Reporter): Promise<Retriever>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NodeRef } from '../model';
|
|
2
|
+
import type { NodeFilter, Retriever } from '../retrieval';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the one node a caller means.
|
|
5
|
+
*
|
|
6
|
+
* @param retriever - Retriever the node is looked up in.
|
|
7
|
+
* @param target - An id, a path or a name.
|
|
8
|
+
* @param filter - Narrows the nodes that count.
|
|
9
|
+
* @returns The one node that fits.
|
|
10
|
+
* @throws {QueryError} When no node fits, or several do. The message lists the candidates with their ids.
|
|
11
|
+
*/
|
|
12
|
+
export declare function nodeOf(retriever: Retriever, target: string, filter: NodeFilter): NodeRef;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web app as one HTML file, with placeholders for the title and the bundle. `HtmlSiteWriter` fills them in.
|
|
3
|
+
* Bun types every `.html` import as a page bundle. With `type: 'text'` the import is the file content.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TEMPLATE_HTML: string;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|