@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,94 @@
|
|
|
1
|
+
import type { DocsBundle } from '../model';
|
|
2
|
+
import { type FileLister, type Reporter, type RepositoryScanner, type Source, type TaskTreeSource } from '../scanner';
|
|
3
|
+
import type { SemanticIndexer } from './embedding';
|
|
4
|
+
import type { ScanOptions } from './scan';
|
|
5
|
+
/**
|
|
6
|
+
* What a `BundleBuilder` works with.
|
|
7
|
+
*
|
|
8
|
+
* @property files - Lists the files of a directory.
|
|
9
|
+
* @property scanner - Reads the files of a scan into graph nodes.
|
|
10
|
+
* @property semantic - Embeds the nodes for search by meaning. `null` leaves that search out of the bundle.
|
|
11
|
+
* @property generator - Recorded in the bundle as the tool that produced it.
|
|
12
|
+
* @property reporter - Receives the problems that do not stop a scan, such as a config file that is not valid.
|
|
13
|
+
*/
|
|
14
|
+
export interface BundleBuilderServices {
|
|
15
|
+
readonly files: FileLister;
|
|
16
|
+
readonly scanner: RepositoryScanner;
|
|
17
|
+
readonly semantic: SemanticIndexer | null;
|
|
18
|
+
readonly generator: string;
|
|
19
|
+
readonly reporter: Reporter;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The directories of one scan, per section.
|
|
23
|
+
*
|
|
24
|
+
* @property skills - Directories the skills are read from.
|
|
25
|
+
* @property docs - Directories the docs are read from.
|
|
26
|
+
* @property code - Directories the code is read from.
|
|
27
|
+
* @property tasks - The task-manager tree of the repository. Empty when the repository has none.
|
|
28
|
+
*/
|
|
29
|
+
export interface ScanSources {
|
|
30
|
+
readonly skills: readonly Source[];
|
|
31
|
+
readonly docs: readonly Source[];
|
|
32
|
+
readonly code: readonly Source[];
|
|
33
|
+
readonly tasks: readonly TaskTreeSource[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @brief Scans a repository into a bundle, with the file lister, scanner and embedder it holds.
|
|
37
|
+
*
|
|
38
|
+
* `createBuilder` in `src/api/services.ts` creates one per scan. `createDocs` writes its bundle into a site,
|
|
39
|
+
* and `ScanLoader` hands it to the query functions. Both first call `sources` to list the files of the scan,
|
|
40
|
+
* then `build` to read them; `ScanLoader` skips `build` when its cache has a bundle for the same files.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* const builder = new BundleBuilder({ files, scanner, semantic: null, generator: GENERATOR, reporter });
|
|
44
|
+
* const bundle = await builder.build(await builder.sources(scan), 'harbor');
|
|
45
|
+
*/
|
|
46
|
+
export declare class BundleBuilder {
|
|
47
|
+
private readonly services;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a builder from the file lister, the scanner, the embedder and the reporter to use.
|
|
50
|
+
*
|
|
51
|
+
* @param services - What the builder works with.
|
|
52
|
+
*/
|
|
53
|
+
constructor(services: BundleBuilderServices);
|
|
54
|
+
/**
|
|
55
|
+
* Lists the files of a scan without reading them.
|
|
56
|
+
*
|
|
57
|
+
* @param options - The repository and the directories to read skills and docs from.
|
|
58
|
+
* @returns The directories of each section with their files, and the task tree of the repository.
|
|
59
|
+
* @throws {SourceError} When the repository or one of the directories does not exist.
|
|
60
|
+
*/
|
|
61
|
+
sources(options: ScanOptions): Promise<ScanSources>;
|
|
62
|
+
/**
|
|
63
|
+
* Reads the files of a scan and links what they declare.
|
|
64
|
+
*
|
|
65
|
+
* @param sources - The directories of each section, from `sources`.
|
|
66
|
+
* @param title - Title of the bundle.
|
|
67
|
+
* @returns The bundle, with a semantic index when the builder has an embedder.
|
|
68
|
+
*/
|
|
69
|
+
build(sources: ScanSources, title: string): Promise<DocsBundle>;
|
|
70
|
+
/**
|
|
71
|
+
* @brief Finds the task-manager tree of a repository.
|
|
72
|
+
*
|
|
73
|
+
* The directory `skills.settings.filetreeRoot` of its `.g3n.config.json` names, `docs/task-manager` by default.
|
|
74
|
+
*
|
|
75
|
+
* @param repository - The repository to look in.
|
|
76
|
+
* @returns One tree with the files below its directory, or none when the directory does not exist.
|
|
77
|
+
*/
|
|
78
|
+
private tasksIn;
|
|
79
|
+
/**
|
|
80
|
+
* Reads the directory of the task tree from the config of a repository, without writing it.
|
|
81
|
+
*
|
|
82
|
+
* @param repo - Absolute path of the repository.
|
|
83
|
+
* @returns The root-relative POSIX path of the tree. The default when the config is not valid.
|
|
84
|
+
*/
|
|
85
|
+
private taskTreeDir;
|
|
86
|
+
/**
|
|
87
|
+
* Picks the directories one section is read from.
|
|
88
|
+
*
|
|
89
|
+
* @param repository - The repository source, read when no directories are given.
|
|
90
|
+
* @param directories - Absolute directories the caller passed. Empty means the repository.
|
|
91
|
+
* @returns The repository, or one source per directory.
|
|
92
|
+
*/
|
|
93
|
+
private sourcesIn;
|
|
94
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DocsBundle } from '../model';
|
|
2
|
+
import type { ScanSources } from './bundle-builder';
|
|
3
|
+
import type { ScanOptions } from './scan';
|
|
4
|
+
/** Keeps the bundle of one scan between runs. */
|
|
5
|
+
export interface BundleCache {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the kept bundle when it was built from the same files.
|
|
8
|
+
*
|
|
9
|
+
* @param fingerprint - Fingerprint of the files as they are now.
|
|
10
|
+
* @returns The bundle, or `null` when nothing is kept or a file changed.
|
|
11
|
+
*/
|
|
12
|
+
read(fingerprint: string): Promise<DocsBundle | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Keeps a bundle, in place of the one kept before.
|
|
15
|
+
*
|
|
16
|
+
* @param fingerprint - Fingerprint of the files the bundle was built from.
|
|
17
|
+
* @param bundle - The bundle to keep.
|
|
18
|
+
*/
|
|
19
|
+
write(fingerprint: string, bundle: DocsBundle): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @brief Names the cache entry of a scan.
|
|
23
|
+
*
|
|
24
|
+
* Two scans share an entry when they read the same repository with the same options and the same version
|
|
25
|
+
* of the tool.
|
|
26
|
+
*
|
|
27
|
+
* @param scan - The options of the scan.
|
|
28
|
+
* @param generator - Name and version of the tool, such as `GENERATOR` in `src/api/services.ts`.
|
|
29
|
+
* @returns A file-name-safe key.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cacheKey(scan: ScanOptions, generator: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* @brief Fingerprints the files of a scan by path, size and modification time, and
|
|
34
|
+
* the directory of its task tree. The fingerprint changes when a file is
|
|
35
|
+
* added, removed or saved, and when the config moves the task tree.
|
|
36
|
+
*
|
|
37
|
+
* @param sources - The directories of the scan with their files.
|
|
38
|
+
* @returns 64 hex digits.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fingerprintOf(sources: ScanSources): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* @brief Keeps a bundle in one file of a cache directory. The first line of the
|
|
43
|
+
* file is the fingerprint, the rest is the bundle as JSON.
|
|
44
|
+
*
|
|
45
|
+
* `openRetriever` creates one per query that scans a repository, in
|
|
46
|
+
* `analyze_out/cache` of that repository. The scan skips that directory, so
|
|
47
|
+
* a cache entry never changes the fingerprint of the next scan.
|
|
48
|
+
*/
|
|
49
|
+
export declare class FileBundleCache implements BundleCache {
|
|
50
|
+
private readonly directory;
|
|
51
|
+
private readonly file;
|
|
52
|
+
/**
|
|
53
|
+
* Creates the cache of one scan.
|
|
54
|
+
*
|
|
55
|
+
* @param directory - Cache directory. Created on the first write.
|
|
56
|
+
* @param key - Name of the entry, from `cacheKey`.
|
|
57
|
+
*/
|
|
58
|
+
constructor(directory: string, key: string);
|
|
59
|
+
/**
|
|
60
|
+
* Reads the entry when its first line is the fingerprint.
|
|
61
|
+
*
|
|
62
|
+
* @param fingerprint - Fingerprint of the files as they are now.
|
|
63
|
+
* @returns The bundle, or `null` when the entry is missing, older or not readable.
|
|
64
|
+
*/
|
|
65
|
+
read(fingerprint: string): Promise<DocsBundle | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Writes the entry to a draft file and renames it into place.
|
|
68
|
+
*
|
|
69
|
+
* @param fingerprint - Fingerprint of the files the bundle was built from.
|
|
70
|
+
* @param bundle - The bundle to keep.
|
|
71
|
+
*/
|
|
72
|
+
write(fingerprint: string, bundle: DocsBundle): Promise<void>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type DocsBundle } from '../model';
|
|
2
|
+
import type { Reporter } from '../scanner';
|
|
3
|
+
import type { BundleBuilder } from './bundle-builder';
|
|
4
|
+
import { type BundleCache } from './bundle-cache';
|
|
5
|
+
import type { ScanOptions } from './scan';
|
|
6
|
+
/** Gets the bundle a query function reads. `loaderOf` in `src/api/source.ts` picks the implementation. */
|
|
7
|
+
export interface BundleLoader {
|
|
8
|
+
/**
|
|
9
|
+
* Loads the bundle to query.
|
|
10
|
+
*
|
|
11
|
+
* @returns The bundle the queries read.
|
|
12
|
+
*/
|
|
13
|
+
load(): Promise<DocsBundle>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @brief Loads the bundle of a site that `createDocs` wrote, from the HTML file alone, without the repository the
|
|
17
|
+
* site was written from. `loaderOf` in `src/api/source.ts` creates one when a caller passes `from`
|
|
18
|
+
* (`--from` on the CLI); `openRetriever` loads it.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SiteLoader implements BundleLoader {
|
|
21
|
+
private readonly file;
|
|
22
|
+
private readonly reporter;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a loader for one site.
|
|
25
|
+
*
|
|
26
|
+
* @param file - Absolute path of the HTML file.
|
|
27
|
+
* @param reporter - Receives a warning when the site cannot be searched by meaning.
|
|
28
|
+
*/
|
|
29
|
+
constructor(file: string, reporter: Reporter);
|
|
30
|
+
/**
|
|
31
|
+
* Reads the HTML file and takes the bundle out of it. Warns when its embeddings are of another format.
|
|
32
|
+
*
|
|
33
|
+
* @returns The bundle the site holds.
|
|
34
|
+
* @throws {SourceError} When the file is missing or is no analyze site.
|
|
35
|
+
*/
|
|
36
|
+
load(): Promise<DocsBundle>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @brief Loads the bundle of a repository: from the cache when no file changed
|
|
40
|
+
* since the last scan, else from a new scan, which it then keeps.
|
|
41
|
+
*
|
|
42
|
+
* `loaderOf` in `src/api/source.ts` creates one when a caller passes no `from`; `openRetriever` loads it.
|
|
43
|
+
*/
|
|
44
|
+
export declare class ScanLoader implements BundleLoader {
|
|
45
|
+
private readonly builder;
|
|
46
|
+
private readonly scan;
|
|
47
|
+
private readonly cache;
|
|
48
|
+
private readonly reporter;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a loader for one repository.
|
|
51
|
+
*
|
|
52
|
+
* @param builder - Builds the bundle when the cache has none.
|
|
53
|
+
* @param scan - The repository to scan.
|
|
54
|
+
* @param cache - Keeps the bundle between runs. `null` scans every time.
|
|
55
|
+
* @param reporter - Receives a warning when the cache cannot be written.
|
|
56
|
+
*/
|
|
57
|
+
constructor(builder: BundleBuilder, scan: ScanOptions, cache: BundleCache | null, reporter: Reporter);
|
|
58
|
+
/**
|
|
59
|
+
* Lists the files of the repository, then reads the cache or scans.
|
|
60
|
+
*
|
|
61
|
+
* @returns The bundle of the repository as it is now.
|
|
62
|
+
* @throws {SourceError} When the repository does not exist.
|
|
63
|
+
*/
|
|
64
|
+
load(): Promise<DocsBundle>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type PackageRole } from '../model';
|
|
3
|
+
/**
|
|
4
|
+
* Schema of the `createDocs` options.
|
|
5
|
+
*
|
|
6
|
+
* @property title - Site title. Default: the name of the repository directory.
|
|
7
|
+
*/
|
|
8
|
+
declare const createDocsSchema: z.ZodPipe<z.ZodObject<{
|
|
9
|
+
onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
|
|
10
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
11
|
+
skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
12
|
+
docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
13
|
+
excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
14
|
+
embeddings: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
title: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
17
|
+
scan: import("./scan").ScanOptions;
|
|
18
|
+
title: string;
|
|
19
|
+
reporter: import("../scanner").Reporter;
|
|
20
|
+
}, {
|
|
21
|
+
onWarning?: import("./options").WarningHandler | undefined;
|
|
22
|
+
repo?: string | undefined;
|
|
23
|
+
skillDirs?: readonly string[] | undefined;
|
|
24
|
+
docDirs?: readonly string[] | undefined;
|
|
25
|
+
excludes?: readonly string[] | undefined;
|
|
26
|
+
embeddings?: boolean | undefined;
|
|
27
|
+
title?: string | undefined;
|
|
28
|
+
}>>;
|
|
29
|
+
/** Options of `createDocs`: what to scan and the title of the site. */
|
|
30
|
+
export type CreateDocsOptions = z.input<typeof createDocsSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Where `createDocs` wrote the site and what the site holds.
|
|
33
|
+
*
|
|
34
|
+
* @property out - Absolute path of the site: `analyze_out/index.html` in the repository.
|
|
35
|
+
* @property bytes - Size of the site in bytes.
|
|
36
|
+
* @property skills - Skills of the bundle.
|
|
37
|
+
* @property docs - Pages of the docs section.
|
|
38
|
+
* @property files - Source files of the code section.
|
|
39
|
+
* @property configs - JSON, TOML and YAML files of the code section, OpenAPI documents and JSON Schemas included.
|
|
40
|
+
* @property packages - Packages of the code section, by role.
|
|
41
|
+
* @property symbols - Symbols of the source files.
|
|
42
|
+
* @property terms - Glossary terms.
|
|
43
|
+
* @property decisions - Decisions.
|
|
44
|
+
* @property operations - Operations of OpenAPI documents.
|
|
45
|
+
* @property definitions - Definitions of JSON Schemas and of OpenAPI documents.
|
|
46
|
+
* @property schemas - SQL files that create tables.
|
|
47
|
+
* @property tables - Tables of those files.
|
|
48
|
+
* @property catalogs - Directories of SQL files that create no table.
|
|
49
|
+
* @property queries - Queries and statements of those directories.
|
|
50
|
+
* @property plans - Plans of the task tree.
|
|
51
|
+
* @property tasks - Tasks of the task tree.
|
|
52
|
+
* @property completedTasks - Tasks with the status `completed`.
|
|
53
|
+
* @property links - Links between nodes: type references, mentions and the like.
|
|
54
|
+
* @property embedded - Nodes that search by meaning can find, and the model that embedded them. `null` without embeddings.
|
|
55
|
+
*/
|
|
56
|
+
export interface CreateDocsResult {
|
|
57
|
+
readonly out: string;
|
|
58
|
+
readonly bytes: number;
|
|
59
|
+
readonly skills: number;
|
|
60
|
+
readonly docs: number;
|
|
61
|
+
readonly files: number;
|
|
62
|
+
readonly configs: number;
|
|
63
|
+
readonly packages: Readonly<Record<PackageRole, number>>;
|
|
64
|
+
readonly symbols: number;
|
|
65
|
+
readonly terms: number;
|
|
66
|
+
readonly decisions: number;
|
|
67
|
+
readonly operations: number;
|
|
68
|
+
readonly definitions: number;
|
|
69
|
+
readonly schemas: number;
|
|
70
|
+
readonly tables: number;
|
|
71
|
+
readonly catalogs: number;
|
|
72
|
+
readonly queries: number;
|
|
73
|
+
readonly plans: number;
|
|
74
|
+
readonly tasks: number;
|
|
75
|
+
readonly completedTasks: number;
|
|
76
|
+
readonly links: number;
|
|
77
|
+
readonly embedded: {
|
|
78
|
+
readonly nodes: number;
|
|
79
|
+
readonly model: string;
|
|
80
|
+
} | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Scans a repository and writes its documentation site to `analyze_out/index.html` in the repository.
|
|
84
|
+
*
|
|
85
|
+
* @param options - What to scan and the title. Default: the working directory.
|
|
86
|
+
* @returns Where the site was written and what it holds.
|
|
87
|
+
* @throws {OptionsError} When the options are not valid.
|
|
88
|
+
* @throws {SourceError} When the repository or one of the directories does not exist.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createDocs(options?: CreateDocsOptions): Promise<CreateDocsResult>;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GraphNode, SemanticIndex } from '../model';
|
|
2
|
+
/** Adds search by meaning to a bundle. `BundleBuilder.build` calls it when the scan has embeddings. */
|
|
3
|
+
export interface SemanticIndexer {
|
|
4
|
+
/**
|
|
5
|
+
* Embeds the searchable nodes of a scan.
|
|
6
|
+
*
|
|
7
|
+
* @param nodes - Nodes of the scan to embed.
|
|
8
|
+
* @returns The index for `DocsBundle.semantic`.
|
|
9
|
+
*/
|
|
10
|
+
index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @brief Embeds nodes with the model that ships with the package.
|
|
14
|
+
*
|
|
15
|
+
* Holds the word table of the model, read on first use from `vectors.bin` and `vocab.txt` in `build/embedding/`
|
|
16
|
+
* when run from source, or beside the bundle when built. `shippedModel` in `src/api/services.ts` imports this
|
|
17
|
+
* module on first use and creates one for each scan with embeddings, with its own directory as `baseDir`.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ShippedModelIndexer implements SemanticIndexer {
|
|
20
|
+
private readonly baseDir;
|
|
21
|
+
private table;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an indexer that has not read the model yet.
|
|
24
|
+
*
|
|
25
|
+
* @param baseDir - Absolute directory that relative paths of the bundled model files resolve against.
|
|
26
|
+
*/
|
|
27
|
+
constructor(baseDir: string);
|
|
28
|
+
/**
|
|
29
|
+
* Reads the model on the first call, then embeds the searchable nodes.
|
|
30
|
+
*
|
|
31
|
+
* @param nodes - Nodes of the scan to embed.
|
|
32
|
+
* @returns The index for `DocsBundle.semantic`.
|
|
33
|
+
*/
|
|
34
|
+
index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
|
|
35
|
+
/**
|
|
36
|
+
* Reads the two files of the model and unpacks the four-bit vectors.
|
|
37
|
+
*
|
|
38
|
+
* @returns The word table of the model, with its vectors unpacked.
|
|
39
|
+
*/
|
|
40
|
+
private load;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief Options a caller passed that do not form a valid call.
|
|
3
|
+
*
|
|
4
|
+
* Holds one issue per problem in `issues`, and its message lists them all. Thrown by `parseOptions` in
|
|
5
|
+
* `src/api/options.ts`; `src/cli/index.ts` prints the usage and exits with 2 for it. Created with
|
|
6
|
+
* `new OptionsError(["limit: must be positive"])`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OptionsError extends Error {
|
|
9
|
+
readonly issues: readonly string[];
|
|
10
|
+
readonly name = "OptionsError";
|
|
11
|
+
/**
|
|
12
|
+
* Creates the error from what is wrong.
|
|
13
|
+
*
|
|
14
|
+
* @param issues - One line per problem: the option and what is wrong with it.
|
|
15
|
+
*/
|
|
16
|
+
constructor(issues: readonly string[]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @brief Error for a query that cannot be answered, such as one for a node that does not exist.
|
|
20
|
+
*
|
|
21
|
+
* Thrown by `src/api/target.ts` and `src/api/search.ts`; the CLI exits with 1 for it. Created with the
|
|
22
|
+
* message, e.g. `new QueryError('No node is called "x".')`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class QueryError extends Error {
|
|
25
|
+
readonly name = "QueryError";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @brief Error for a repository, a directory or a site file that is missing or cannot be read.
|
|
29
|
+
*
|
|
30
|
+
* Thrown by the bundle builder, loader and site reader in `src/api/`; the CLI exits with 1 for it. Created
|
|
31
|
+
* with the message, e.g. `new SourceError('Site not found: /path/site.html')`.
|
|
32
|
+
*/
|
|
33
|
+
export declare class SourceError extends Error {
|
|
34
|
+
readonly name = "SourceError";
|
|
35
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { NodeFilter, NodeSummary, Retriever } from '../retrieval';
|
|
3
|
+
/**
|
|
4
|
+
* Schema of the `list` options.
|
|
5
|
+
*
|
|
6
|
+
* @property limit - Most rows. Absent lists everything.
|
|
7
|
+
*/
|
|
8
|
+
declare const listSchema: 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
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
50
|
+
source: import("./source").BundleSource;
|
|
51
|
+
reporter: import("../scanner").Reporter;
|
|
52
|
+
request: {
|
|
53
|
+
filter: NodeFilter;
|
|
54
|
+
limit: number | null;
|
|
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
|
+
limit?: number | undefined;
|
|
68
|
+
}>>;
|
|
69
|
+
/** Options of `list`: the filter, the limit, and the bundle to list. */
|
|
70
|
+
export type ListOptions = z.input<typeof listSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* One `list` on a loaded bundle.
|
|
73
|
+
*
|
|
74
|
+
* @property filter - Narrows the nodes that count.
|
|
75
|
+
* @property limit - Most rows. `null` lists everything.
|
|
76
|
+
*/
|
|
77
|
+
export interface ListRequest {
|
|
78
|
+
readonly filter: NodeFilter;
|
|
79
|
+
readonly limit: number | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What `list` finds. The CLI prints it with `list --json`.
|
|
83
|
+
*
|
|
84
|
+
* @property nodes - The nodes, in the order of the navigation.
|
|
85
|
+
*/
|
|
86
|
+
export interface ListResult {
|
|
87
|
+
readonly nodes: readonly NodeSummary[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Lists the pages and entries of a loaded bundle.
|
|
91
|
+
*
|
|
92
|
+
* @param retriever - The loaded bundle to list.
|
|
93
|
+
* @param request - The filter and the limit.
|
|
94
|
+
* @returns The nodes, in the order of the navigation.
|
|
95
|
+
*/
|
|
96
|
+
export declare function listIn(retriever: Retriever, request: ListRequest): ListResult;
|
|
97
|
+
/**
|
|
98
|
+
* Lists pages and entries.
|
|
99
|
+
*
|
|
100
|
+
* @param options - The filter, the limit, and the repository or site to list. Default: every node of the working directory.
|
|
101
|
+
* @returns The nodes, in the order of the navigation.
|
|
102
|
+
* @throws {OptionsError} When the options are not valid.
|
|
103
|
+
* @throws {SourceError} When the repository or the site cannot be read.
|
|
104
|
+
*/
|
|
105
|
+
export declare function list(options?: ListOptions): Promise<ListResult>;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { NodeFilter } from '../retrieval';
|
|
3
|
+
import { type Reporter } from '../scanner';
|
|
4
|
+
/** Receives problems that do not stop a call, such as a scan that could not be cached. */
|
|
5
|
+
export type WarningHandler = (message: string) => void;
|
|
6
|
+
/** The option every function takes to hear about warnings. Without it, warnings are dropped. */
|
|
7
|
+
export declare const warningShape: {
|
|
8
|
+
onWarning: z.ZodOptional<z.ZodCustom<WarningHandler, WarningHandler>>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The options that narrow the nodes a query looks at.
|
|
12
|
+
*
|
|
13
|
+
* @property kinds - Only nodes of these kinds. Empty or absent keeps every kind.
|
|
14
|
+
* @property section - Only nodes of this section.
|
|
15
|
+
*/
|
|
16
|
+
export declare const filterShape: {
|
|
17
|
+
kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
18
|
+
class: "class";
|
|
19
|
+
decision: "decision";
|
|
20
|
+
definition: "definition";
|
|
21
|
+
enum: "enum";
|
|
22
|
+
field: "field";
|
|
23
|
+
file: "file";
|
|
24
|
+
folder: "folder";
|
|
25
|
+
function: "function";
|
|
26
|
+
interface: "interface";
|
|
27
|
+
namespace: "namespace";
|
|
28
|
+
operation: "operation";
|
|
29
|
+
package: "package";
|
|
30
|
+
parameter: "parameter";
|
|
31
|
+
phase: "phase";
|
|
32
|
+
plan: "plan";
|
|
33
|
+
query: "query";
|
|
34
|
+
struct: "struct";
|
|
35
|
+
table: "table";
|
|
36
|
+
task: "task";
|
|
37
|
+
term: "term";
|
|
38
|
+
trait: "trait";
|
|
39
|
+
type: "type";
|
|
40
|
+
}>>>>;
|
|
41
|
+
section: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
code: "code";
|
|
43
|
+
database: "database";
|
|
44
|
+
docs: "docs";
|
|
45
|
+
skills: "skills";
|
|
46
|
+
tasks: "tasks";
|
|
47
|
+
}>>;
|
|
48
|
+
};
|
|
49
|
+
/** The filter options after validation: `kinds` and `section`, both optional. */
|
|
50
|
+
type FilterFields = z.output<z.ZodObject<typeof filterShape>>;
|
|
51
|
+
/**
|
|
52
|
+
* Turns validated filter options into the filter the retriever takes.
|
|
53
|
+
*
|
|
54
|
+
* @param fields - Validated filter options, from `filterShape`.
|
|
55
|
+
* @returns The filter the retriever takes. Absent options keep every node.
|
|
56
|
+
*/
|
|
57
|
+
export declare function filterOf(fields: FilterFields): NodeFilter;
|
|
58
|
+
/**
|
|
59
|
+
* Turns the warning option into the reporter the services take.
|
|
60
|
+
*
|
|
61
|
+
* @param onWarning - The caller's handler, or `undefined` to drop the warnings.
|
|
62
|
+
* @returns A reporter that hands each warning to the handler, or drops it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function reporterOf(onWarning: WarningHandler | undefined): Reporter;
|
|
65
|
+
/**
|
|
66
|
+
* Validates the options a caller passed against the schema of a function.
|
|
67
|
+
*
|
|
68
|
+
* @param schema - The schema of the options, with its transform.
|
|
69
|
+
* @param input - The options the caller passed, not yet validated.
|
|
70
|
+
* @returns The options after the transform.
|
|
71
|
+
* @throws {OptionsError} When the options do not fit the schema. Its `issues` name each problem.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseOptions<Schema extends z.ZodType>(schema: Schema, input: unknown): z.output<Schema>;
|
|
74
|
+
export {};
|