@g3nomaly/analyze 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +71 -2
  3. package/dist/THIRD_PARTY_LICENSES.txt +1904 -0
  4. package/dist/api/bundle-builder.d.ts +75 -0
  5. package/dist/api/bundle-cache.d.ts +70 -0
  6. package/dist/api/bundle-loader.d.ts +58 -0
  7. package/dist/api/create-docs.d.ts +72 -0
  8. package/dist/api/embedding.d.ts +32 -0
  9. package/dist/api/errors.d.ts +28 -0
  10. package/dist/api/list.d.ts +106 -0
  11. package/dist/api/options.d.ts +78 -0
  12. package/dist/api/refs.d.ts +133 -0
  13. package/dist/api/scan.d.ts +44 -0
  14. package/dist/api/search.d.ts +126 -0
  15. package/dist/api/services.d.ts +7 -0
  16. package/dist/api/show.d.ts +104 -0
  17. package/dist/api/site-reader.d.ts +11 -0
  18. package/dist/api/site-writer.d.ts +20 -0
  19. package/dist/api/source.d.ts +46 -0
  20. package/dist/api/target.d.ts +10 -0
  21. package/dist/api/template.d.ts +5 -0
  22. package/dist/assets/tree-sitter-c-sharp.wasm +0 -0
  23. package/dist/assets/tree-sitter-c.wasm +0 -0
  24. package/dist/assets/tree-sitter-cpp.wasm +0 -0
  25. package/dist/assets/tree-sitter-go.wasm +0 -0
  26. package/dist/assets/tree-sitter-java.wasm +0 -0
  27. package/dist/assets/tree-sitter-javascript.wasm +0 -0
  28. package/dist/assets/tree-sitter-kotlin.wasm +0 -0
  29. package/dist/assets/tree-sitter-php.wasm +0 -0
  30. package/dist/assets/tree-sitter-python.wasm +0 -0
  31. package/dist/assets/tree-sitter-ruby.wasm +0 -0
  32. package/dist/assets/tree-sitter-rust.wasm +0 -0
  33. package/dist/assets/tree-sitter-scala.wasm +0 -0
  34. package/dist/assets/tree-sitter-tsx.wasm +0 -0
  35. package/dist/assets/tree-sitter-typescript.wasm +0 -0
  36. package/dist/assets/vectors.bin +0 -0
  37. package/dist/assets/vocab.txt +33731 -0
  38. package/dist/cli.js +8885 -0
  39. package/dist/embeddings/abbreviations.d.ts +7 -0
  40. package/dist/embeddings/index-builder.d.ts +10 -0
  41. package/dist/embeddings/index.d.ts +10 -0
  42. package/dist/embeddings/model.d.ts +113 -0
  43. package/dist/embeddings/searcher.d.ts +67 -0
  44. package/dist/embeddings/vectors.d.ts +75 -0
  45. package/dist/embeddings/words.d.ts +42 -0
  46. package/dist/index.d.ts +9 -0
  47. package/dist/index.js +8329 -0
  48. package/dist/model/index.d.ts +560 -0
  49. package/dist/model/registry.d.ts +494 -0
  50. package/dist/query/graph.d.ts +66 -0
  51. package/dist/query/index.d.ts +4 -0
  52. package/dist/query/name-search.d.ts +47 -0
  53. package/dist/query/semantic.d.ts +30 -0
  54. package/dist/query/text.d.ts +22 -0
  55. package/dist/retrieval/describe.d.ts +26 -0
  56. package/dist/retrieval/filter.d.ts +17 -0
  57. package/dist/retrieval/index.d.ts +7 -0
  58. package/dist/retrieval/markdown.d.ts +16 -0
  59. package/dist/retrieval/report.d.ts +214 -0
  60. package/dist/retrieval/resolve.d.ts +27 -0
  61. package/dist/retrieval/retriever.d.ts +94 -0
  62. package/dist/retrieval/summary.d.ts +24 -0
  63. package/dist/scanner/code/doc/clean.d.ts +10 -0
  64. package/dist/scanner/code/doc/index.d.ts +6 -0
  65. package/dist/scanner/code/doc/markdown.d.ts +3 -0
  66. package/dist/scanner/code/doc/python.d.ts +3 -0
  67. package/dist/scanner/code/doc/tagged.d.ts +10 -0
  68. package/dist/scanner/code/doc/types.d.ts +22 -0
  69. package/dist/scanner/code/doc/xml.d.ts +3 -0
  70. package/dist/scanner/code/example.d.ts +36 -0
  71. package/dist/scanner/code/extract.d.ts +78 -0
  72. package/dist/scanner/code/grammar.d.ts +29 -0
  73. package/dist/scanner/code/language.d.ts +149 -0
  74. package/dist/scanner/code/languages/c-family.d.ts +5 -0
  75. package/dist/scanner/code/languages/csharp.d.ts +3 -0
  76. package/dist/scanner/code/languages/ecmascript.d.ts +7 -0
  77. package/dist/scanner/code/languages/go.d.ts +3 -0
  78. package/dist/scanner/code/languages/index.d.ts +19 -0
  79. package/dist/scanner/code/languages/java.d.ts +3 -0
  80. package/dist/scanner/code/languages/kotlin.d.ts +3 -0
  81. package/dist/scanner/code/languages/php.d.ts +3 -0
  82. package/dist/scanner/code/languages/python.d.ts +3 -0
  83. package/dist/scanner/code/languages/ruby.d.ts +3 -0
  84. package/dist/scanner/code/languages/rust.d.ts +3 -0
  85. package/dist/scanner/code/languages/scala.d.ts +3 -0
  86. package/dist/scanner/code/languages/shared.d.ts +17 -0
  87. package/dist/scanner/code/planner.d.ts +71 -0
  88. package/dist/scanner/code/symbols.d.ts +68 -0
  89. package/dist/scanner/code/types.d.ts +93 -0
  90. package/dist/scanner/content.d.ts +38 -0
  91. package/dist/scanner/decisions/parse.d.ts +28 -0
  92. package/dist/scanner/decisions/planner.d.ts +30 -0
  93. package/dist/scanner/docs.d.ts +52 -0
  94. package/dist/scanner/files.d.ts +60 -0
  95. package/dist/scanner/glossary/parse.d.ts +30 -0
  96. package/dist/scanner/glossary/planner.d.ts +42 -0
  97. package/dist/scanner/glossary/terms.d.ts +86 -0
  98. package/dist/scanner/graph/builder.d.ts +55 -0
  99. package/dist/scanner/highlight.d.ts +31 -0
  100. package/dist/scanner/index.d.ts +40 -0
  101. package/dist/scanner/markdown/frontmatter.d.ts +9 -0
  102. package/dist/scanner/markdown/links.d.ts +50 -0
  103. package/dist/scanner/markdown/outline.d.ts +27 -0
  104. package/dist/scanner/markdown/renderer.d.ts +44 -0
  105. package/dist/scanner/openapi/planner.d.ts +84 -0
  106. package/dist/scanner/reporter.d.ts +7 -0
  107. package/dist/scanner/scanner.d.ts +52 -0
  108. package/dist/scanner/schema/definitions.d.ts +69 -0
  109. package/dist/scanner/schema/describe.d.ts +79 -0
  110. package/dist/scanner/schema/planner.d.ts +46 -0
  111. package/dist/scanner/schema/registry.d.ts +61 -0
  112. package/dist/scanner/skills/classify.d.ts +20 -0
  113. package/dist/scanner/skills/layout.d.ts +28 -0
  114. package/dist/scanner/skills/planner.d.ts +46 -0
  115. package/dist/scanner/specs.d.ts +50 -0
  116. package/dist/scanner/sql/catalog.d.ts +84 -0
  117. package/dist/scanner/sql/cursor.d.ts +107 -0
  118. package/dist/scanner/sql/database.d.ts +48 -0
  119. package/dist/scanner/sql/parse.d.ts +87 -0
  120. package/dist/scanner/sql/planner.d.ts +65 -0
  121. package/dist/scanner/sql/query.d.ts +60 -0
  122. package/dist/scanner/sql/registry.d.ts +49 -0
  123. package/dist/scanner/sql/source.d.ts +9 -0
  124. package/dist/scanner/sql/statements.d.ts +36 -0
  125. package/dist/scanner/sql/tokens.d.ts +38 -0
  126. package/dist/scanner/tasks/layout.d.ts +40 -0
  127. package/dist/scanner/tasks/planner.d.ts +75 -0
  128. package/dist/scanner/tasks/schema.d.ts +88 -0
  129. package/dist/scanner/text.d.ts +14 -0
  130. package/package.json +104 -4
@@ -0,0 +1,75 @@
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
+ /** What a `BundleBuilder` works with. */
6
+ export interface BundleBuilderServices {
7
+ readonly files: FileLister;
8
+ readonly scanner: RepositoryScanner;
9
+ /** Embeds the nodes for search by meaning. `null` leaves that search out of the bundle. */
10
+ readonly semantic: SemanticIndexer | null;
11
+ /** Recorded in the bundle as the tool that produced it. */
12
+ readonly generator: string;
13
+ /** Receives the problems that do not stop a scan, such as a config file that is not valid. */
14
+ readonly reporter: Reporter;
15
+ }
16
+ /** The directories of one scan, per section. */
17
+ export interface ScanSources {
18
+ readonly skills: readonly Source[];
19
+ readonly docs: readonly Source[];
20
+ readonly code: readonly Source[];
21
+ /** The task-manager tree of the repository. Empty when the repository has none. */
22
+ readonly tasks: readonly TaskTreeSource[];
23
+ }
24
+ /**
25
+ * Scans a repository into a bundle, with the file lister, scanner and embedder it holds.
26
+ *
27
+ * `createBuilder` in `src/api/services.ts` creates one per scan. `createDocs` writes its bundle into a site,
28
+ * and `ScanLoader` hands it to the query functions. Both first call `sources` to list the files of the scan,
29
+ * then `build` to read them; `ScanLoader` skips `build` when its cache has a bundle for the same files.
30
+ *
31
+ * @example
32
+ * const builder = new BundleBuilder({ files, scanner, semantic: null, generator: GENERATOR, reporter });
33
+ * const bundle = await builder.build(await builder.sources(scan), 'harbor');
34
+ */
35
+ export declare class BundleBuilder {
36
+ private readonly services;
37
+ /** Creates a builder from the file lister, the scanner, the embedder and the reporter to use. */
38
+ constructor(services: BundleBuilderServices);
39
+ /**
40
+ * Lists the files of a scan without reading them.
41
+ *
42
+ * @param options - The repository and the directories to read skills and docs from.
43
+ * @returns The directories of each section with their files, and the task tree of the repository.
44
+ * @throws {SourceError} When the repository or one of the directories does not exist.
45
+ */
46
+ sources(options: ScanOptions): Promise<ScanSources>;
47
+ /**
48
+ * Reads the files of a scan and links what they declare.
49
+ *
50
+ * @param sources - The directories of each section, from `sources`.
51
+ * @returns The bundle, with a semantic index when the builder has an embedder.
52
+ */
53
+ build(sources: ScanSources, title: string): Promise<DocsBundle>;
54
+ /**
55
+ * Finds the task-manager tree of a repository: the directory `skills.settings.filetreeRoot` of its
56
+ * `.g3n.config.json` names, `docs/task-manager` by default.
57
+ *
58
+ * @returns One tree with the files below its directory, or none when the directory does not exist.
59
+ */
60
+ private tasksIn;
61
+ /**
62
+ * Reads the directory of the task tree from the config of a repository, without writing it.
63
+ *
64
+ * @param repo - Absolute path of the repository.
65
+ * @returns The root-relative POSIX path of the tree. The default when the config is not valid.
66
+ */
67
+ private taskTreeDir;
68
+ /**
69
+ * Picks the directories one section is read from.
70
+ *
71
+ * @param directories - Absolute directories the caller passed. Empty means the repository.
72
+ * @returns The repository, or one source per directory.
73
+ */
74
+ private sourcesIn;
75
+ }
@@ -0,0 +1,70 @@
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
+ * Names the cache entry of a scan. Two scans share an entry when they read
23
+ * the same repository with the same options and the same version of the tool.
24
+ *
25
+ * @param generator - Name and version of the tool, such as `GENERATOR` in `src/api/services.ts`.
26
+ * @returns A file-name-safe key.
27
+ */
28
+ export declare function cacheKey(scan: ScanOptions, generator: string): string;
29
+ /**
30
+ * Fingerprints the files of a scan by path, size and modification time, and
31
+ * the directory of its task tree. The fingerprint changes when a file is
32
+ * added, removed or saved, and when the config moves the task tree.
33
+ *
34
+ * @param sources - The directories of the scan with their files.
35
+ * @returns 64 hex digits.
36
+ */
37
+ export declare function fingerprintOf(sources: ScanSources): Promise<string>;
38
+ /**
39
+ * Keeps a bundle in one file of a cache directory. The first line of the
40
+ * file is the fingerprint, the rest is the bundle as JSON.
41
+ *
42
+ * `openRetriever` creates one per query that scans a repository, in
43
+ * `analyze_out/cache` of that repository. The scan skips that directory, so
44
+ * a cache entry never changes the fingerprint of the next scan.
45
+ */
46
+ export declare class FileBundleCache implements BundleCache {
47
+ private readonly directory;
48
+ private readonly file;
49
+ /**
50
+ * Creates the cache of one scan.
51
+ *
52
+ * @param directory - Cache directory. Created on the first write.
53
+ * @param key - Name of the entry, from `cacheKey`.
54
+ */
55
+ constructor(directory: string, key: string);
56
+ /**
57
+ * Reads the entry when its first line is the fingerprint.
58
+ *
59
+ * @param fingerprint - Fingerprint of the files as they are now.
60
+ * @returns The bundle, or `null` when the entry is missing, older or not readable.
61
+ */
62
+ read(fingerprint: string): Promise<DocsBundle | null>;
63
+ /**
64
+ * Writes the entry to a draft file and renames it into place.
65
+ *
66
+ * @param fingerprint - Fingerprint of the files the bundle was built from.
67
+ * @param bundle - The bundle to keep.
68
+ */
69
+ write(fingerprint: string, bundle: DocsBundle): Promise<void>;
70
+ }
@@ -0,0 +1,58 @@
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
+ /** Loads the bundle to query. */
9
+ load(): Promise<DocsBundle>;
10
+ }
11
+ /**
12
+ * Loads the bundle of a site that `createDocs` wrote, from the HTML file alone, without the repository the
13
+ * site was written from. `loaderOf` in `src/api/source.ts` creates one when a caller passes `from`
14
+ * (`--from` on the CLI); `openRetriever` loads it.
15
+ */
16
+ export declare class SiteLoader implements BundleLoader {
17
+ private readonly file;
18
+ private readonly reporter;
19
+ /**
20
+ * Creates a loader for one site.
21
+ *
22
+ * @param file - Absolute path of the HTML file.
23
+ * @param reporter - Receives a warning when the site cannot be searched by meaning.
24
+ */
25
+ constructor(file: string, reporter: Reporter);
26
+ /**
27
+ * Reads the HTML file and takes the bundle out of it. Warns when its embeddings are of another format.
28
+ *
29
+ * @throws {SourceError} When the file is missing or is no analyze site.
30
+ */
31
+ load(): Promise<DocsBundle>;
32
+ }
33
+ /**
34
+ * Loads the bundle of a repository: from the cache when no file changed
35
+ * since the last scan, else from a new scan, which it then keeps.
36
+ *
37
+ * `loaderOf` in `src/api/source.ts` creates one when a caller passes no `from`; `openRetriever` loads it.
38
+ */
39
+ export declare class ScanLoader implements BundleLoader {
40
+ private readonly builder;
41
+ private readonly scan;
42
+ private readonly cache;
43
+ private readonly reporter;
44
+ /**
45
+ * Creates a loader for one repository.
46
+ *
47
+ * @param cache - Keeps the bundle between runs. `null` scans every time.
48
+ * @param reporter - Receives a warning when the cache cannot be written.
49
+ */
50
+ constructor(builder: BundleBuilder, scan: ScanOptions, cache: BundleCache | null, reporter: Reporter);
51
+ /**
52
+ * Lists the files of the repository, then reads the cache or scans.
53
+ *
54
+ * @returns The bundle of the repository as it is now.
55
+ * @throws {SourceError} When the repository does not exist.
56
+ */
57
+ load(): Promise<DocsBundle>;
58
+ }
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ declare const createDocsSchema: z.ZodPipe<z.ZodObject<{
3
+ onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
4
+ repo: z.ZodOptional<z.ZodString>;
5
+ skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
6
+ docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
7
+ excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
8
+ embeddings: z.ZodOptional<z.ZodBoolean>;
9
+ title: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strict>, z.ZodTransform<{
11
+ scan: import("./scan").ScanOptions;
12
+ title: string;
13
+ reporter: import("../scanner").Reporter;
14
+ }, {
15
+ onWarning?: import("./options").WarningHandler | undefined;
16
+ repo?: string | undefined;
17
+ skillDirs?: readonly string[] | undefined;
18
+ docDirs?: readonly string[] | undefined;
19
+ excludes?: readonly string[] | undefined;
20
+ embeddings?: boolean | undefined;
21
+ title?: string | undefined;
22
+ }>>;
23
+ /** Options of `createDocs`: what to scan and the title of the site. */
24
+ export type CreateDocsOptions = z.input<typeof createDocsSchema>;
25
+ /** Where `createDocs` wrote the site and what the site holds. */
26
+ export interface CreateDocsResult {
27
+ /** Absolute path of the site: `analyze_out/index.html` in the repository. */
28
+ readonly out: string;
29
+ readonly bytes: number;
30
+ readonly skills: number;
31
+ readonly docs: number;
32
+ readonly files: number;
33
+ readonly symbols: number;
34
+ /** Glossary terms. */
35
+ readonly terms: number;
36
+ readonly decisions: number;
37
+ /** Operations of OpenAPI documents. */
38
+ readonly operations: number;
39
+ /** Definitions of JSON Schemas and of OpenAPI documents. */
40
+ readonly definitions: number;
41
+ /** SQL files that create tables. */
42
+ readonly schemas: number;
43
+ /** Tables of those files. */
44
+ readonly tables: number;
45
+ /** Directories of SQL files that create no table. */
46
+ readonly catalogs: number;
47
+ /** Queries and statements of those directories. */
48
+ readonly queries: number;
49
+ /** Plans of the task tree. */
50
+ readonly plans: number;
51
+ /** Tasks of the task tree. */
52
+ readonly tasks: number;
53
+ /** Tasks with the status `completed`. */
54
+ readonly completedTasks: number;
55
+ /** Links between nodes: type references, mentions and the like. */
56
+ readonly links: number;
57
+ /** Nodes that search by meaning can find, and the model that embedded them. `null` without embeddings. */
58
+ readonly embedded: {
59
+ readonly nodes: number;
60
+ readonly model: string;
61
+ } | null;
62
+ }
63
+ /**
64
+ * Scans a repository and writes its documentation site to `analyze_out/index.html` in the repository.
65
+ *
66
+ * @param options - What to scan and the title. Default: the working directory.
67
+ * @returns Where the site was written and what it holds.
68
+ * @throws {OptionsError} When the options are not valid.
69
+ * @throws {SourceError} When the repository or one of the directories does not exist.
70
+ */
71
+ export declare function createDocs(options?: CreateDocsOptions): Promise<CreateDocsResult>;
72
+ export {};
@@ -0,0 +1,32 @@
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
+ * @returns The index for `DocsBundle.semantic`.
8
+ */
9
+ index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
10
+ }
11
+ /**
12
+ * Embeds nodes with the model that ships with the package. Holds the word table of the model, read on first
13
+ * use from two files: `vectors.bin` and `vocab.txt` in `build/embedding/` when run from source, or beside the
14
+ * bundle when built.
15
+ *
16
+ * `shippedModel` in `src/api/services.ts` imports this module on first use and creates one for each scan with
17
+ * 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
+ /** Reads the model on the first call, then embeds the searchable nodes into an index for `DocsBundle.semantic`. */
29
+ index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
30
+ /** Reads the two files of the model and unpacks the four-bit vectors into a word table. */
31
+ private load;
32
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Options a caller passed that do not form a valid call. Holds one issue per problem.
3
+ * Thrown by `parseOptions` in `src/api/options.ts`; `src/cli/index.ts` prints the usage and exits with 2 for it.
4
+ */
5
+ export declare class OptionsError extends Error {
6
+ readonly issues: readonly string[];
7
+ readonly name = "OptionsError";
8
+ /**
9
+ * Creates the error from what is wrong.
10
+ *
11
+ * @param issues - One line per problem: the option and what is wrong with it.
12
+ */
13
+ constructor(issues: readonly string[]);
14
+ }
15
+ /**
16
+ * A query that cannot be answered, such as one for a node that does not exist. Thrown by `src/api/target.ts`
17
+ * and `src/api/search.ts`; the CLI exits with 1 for it.
18
+ */
19
+ export declare class QueryError extends Error {
20
+ readonly name = "QueryError";
21
+ }
22
+ /**
23
+ * A repository, a directory or a site file that is missing or cannot be read. Thrown by the bundle builder,
24
+ * loader and site reader in `src/api/`; the CLI exits with 1 for it.
25
+ */
26
+ export declare class SourceError extends Error {
27
+ readonly name = "SourceError";
28
+ }
@@ -0,0 +1,106 @@
1
+ import { z } from 'zod';
2
+ import type { NodeFilter, NodeSummary, Retriever } from '../retrieval';
3
+ declare const listSchema: z.ZodPipe<z.ZodObject<{
4
+ onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
5
+ kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
6
+ agent: "agent";
7
+ api: "api";
8
+ asset: "asset";
9
+ catalog: "catalog";
10
+ class: "class";
11
+ database: "database";
12
+ decision: "decision";
13
+ decisions: "decisions";
14
+ definition: "definition";
15
+ document: "document";
16
+ enum: "enum";
17
+ field: "field";
18
+ folder: "folder";
19
+ function: "function";
20
+ glossary: "glossary";
21
+ hook: "hook";
22
+ interface: "interface";
23
+ json: "json";
24
+ method: "method";
25
+ namespace: "namespace";
26
+ operation: "operation";
27
+ parameter: "parameter";
28
+ phase: "phase";
29
+ plan: "plan";
30
+ query: "query";
31
+ reference: "reference";
32
+ schema: "schema";
33
+ section: "section";
34
+ skill: "skill";
35
+ source: "source";
36
+ struct: "struct";
37
+ table: "table";
38
+ task: "task";
39
+ term: "term";
40
+ trait: "trait";
41
+ type: "type";
42
+ }>>>>;
43
+ section: z.ZodOptional<z.ZodEnum<{
44
+ code: "code";
45
+ database: "database";
46
+ docs: "docs";
47
+ skills: "skills";
48
+ tasks: "tasks";
49
+ }>>;
50
+ repo: z.ZodOptional<z.ZodString>;
51
+ skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
52
+ docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
53
+ excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
54
+ embeddings: z.ZodOptional<z.ZodBoolean>;
55
+ from: z.ZodOptional<z.ZodString>;
56
+ cache: z.ZodOptional<z.ZodBoolean>;
57
+ limit: z.ZodOptional<z.ZodNumber>;
58
+ }, z.core.$strict>, z.ZodTransform<{
59
+ source: import("./source").BundleSource;
60
+ reporter: import("../scanner").Reporter;
61
+ request: {
62
+ filter: NodeFilter;
63
+ limit: number | null;
64
+ };
65
+ }, {
66
+ onWarning?: import("./options").WarningHandler | undefined;
67
+ kinds?: readonly ("agent" | "api" | "asset" | "catalog" | "class" | "database" | "decision" | "decisions" | "definition" | "document" | "enum" | "field" | "folder" | "function" | "glossary" | "hook" | "interface" | "json" | "method" | "namespace" | "operation" | "parameter" | "phase" | "plan" | "query" | "reference" | "schema" | "section" | "skill" | "source" | "struct" | "table" | "task" | "term" | "trait" | "type")[] | undefined;
68
+ section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
69
+ repo?: string | undefined;
70
+ skillDirs?: readonly string[] | undefined;
71
+ docDirs?: readonly string[] | undefined;
72
+ excludes?: readonly string[] | undefined;
73
+ embeddings?: boolean | undefined;
74
+ from?: string | undefined;
75
+ cache?: boolean | undefined;
76
+ limit?: number | undefined;
77
+ }>>;
78
+ /** Options of `list`: the filter, the limit, and the bundle to list. */
79
+ export type ListOptions = z.input<typeof listSchema>;
80
+ /** One `list` on a loaded bundle. */
81
+ export interface ListRequest {
82
+ readonly filter: NodeFilter;
83
+ /** Most rows. `null` lists everything. */
84
+ readonly limit: number | null;
85
+ }
86
+ /** What `list` finds. The CLI prints it with `list --json`. */
87
+ export interface ListResult {
88
+ readonly nodes: readonly NodeSummary[];
89
+ }
90
+ /**
91
+ * Lists the pages and entries of a loaded bundle.
92
+ *
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,78 @@
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
+ /** The options that narrow the nodes a query looks at. */
11
+ export declare const filterShape: {
12
+ /** Only nodes of these kinds. Empty or absent keeps every kind. */
13
+ kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
14
+ agent: "agent";
15
+ api: "api";
16
+ asset: "asset";
17
+ catalog: "catalog";
18
+ class: "class";
19
+ database: "database";
20
+ decision: "decision";
21
+ decisions: "decisions";
22
+ definition: "definition";
23
+ document: "document";
24
+ enum: "enum";
25
+ field: "field";
26
+ folder: "folder";
27
+ function: "function";
28
+ glossary: "glossary";
29
+ hook: "hook";
30
+ interface: "interface";
31
+ json: "json";
32
+ method: "method";
33
+ namespace: "namespace";
34
+ operation: "operation";
35
+ parameter: "parameter";
36
+ phase: "phase";
37
+ plan: "plan";
38
+ query: "query";
39
+ reference: "reference";
40
+ schema: "schema";
41
+ section: "section";
42
+ skill: "skill";
43
+ source: "source";
44
+ struct: "struct";
45
+ table: "table";
46
+ task: "task";
47
+ term: "term";
48
+ trait: "trait";
49
+ type: "type";
50
+ }>>>>;
51
+ /** Only nodes of this section. */
52
+ section: z.ZodOptional<z.ZodEnum<{
53
+ code: "code";
54
+ database: "database";
55
+ docs: "docs";
56
+ skills: "skills";
57
+ tasks: "tasks";
58
+ }>>;
59
+ };
60
+ /** The filter options after validation. */
61
+ type FilterFields = z.output<z.ZodObject<typeof filterShape>>;
62
+ /**
63
+ * Turns validated filter options into the filter the retriever takes.
64
+ *
65
+ * @returns The filter. Absent options keep every node.
66
+ */
67
+ export declare function filterOf(fields: FilterFields): NodeFilter;
68
+ /** Turns the warning option into the reporter the services take: one that hands each warning to the handler, or drops it. */
69
+ export declare function reporterOf(onWarning: WarningHandler | undefined): Reporter;
70
+ /**
71
+ * Validates the options a caller passed against the schema of a function.
72
+ *
73
+ * @param schema - The schema of the options, with its transform.
74
+ * @returns The options after the transform.
75
+ * @throws {OptionsError} When the options do not fit the schema. Its `issues` name each problem.
76
+ */
77
+ export declare function parseOptions<Schema extends z.ZodType>(schema: Schema, input: unknown): z.output<Schema>;
78
+ export {};
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ import type { NodeFilter, NodeSummary, ReferenceOptions, References, Retriever } from '../retrieval';
3
+ declare const refsSchema: z.ZodPipe<z.ZodObject<{
4
+ onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
5
+ kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
6
+ agent: "agent";
7
+ api: "api";
8
+ asset: "asset";
9
+ catalog: "catalog";
10
+ class: "class";
11
+ database: "database";
12
+ decision: "decision";
13
+ decisions: "decisions";
14
+ definition: "definition";
15
+ document: "document";
16
+ enum: "enum";
17
+ field: "field";
18
+ folder: "folder";
19
+ function: "function";
20
+ glossary: "glossary";
21
+ hook: "hook";
22
+ interface: "interface";
23
+ json: "json";
24
+ method: "method";
25
+ namespace: "namespace";
26
+ operation: "operation";
27
+ parameter: "parameter";
28
+ phase: "phase";
29
+ plan: "plan";
30
+ query: "query";
31
+ reference: "reference";
32
+ schema: "schema";
33
+ section: "section";
34
+ skill: "skill";
35
+ source: "source";
36
+ struct: "struct";
37
+ table: "table";
38
+ task: "task";
39
+ term: "term";
40
+ trait: "trait";
41
+ type: "type";
42
+ }>>>>;
43
+ section: z.ZodOptional<z.ZodEnum<{
44
+ code: "code";
45
+ database: "database";
46
+ docs: "docs";
47
+ skills: "skills";
48
+ tasks: "tasks";
49
+ }>>;
50
+ repo: z.ZodOptional<z.ZodString>;
51
+ skillDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
52
+ docDirs: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
53
+ excludes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
54
+ embeddings: z.ZodOptional<z.ZodBoolean>;
55
+ from: z.ZodOptional<z.ZodString>;
56
+ cache: z.ZodOptional<z.ZodBoolean>;
57
+ target: z.ZodString;
58
+ incoming: z.ZodOptional<z.ZodBoolean>;
59
+ outgoing: z.ZodOptional<z.ZodBoolean>;
60
+ edges: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
61
+ affects: "affects";
62
+ depends: "depends";
63
+ extends: "extends";
64
+ mentions: "mentions";
65
+ names: "names";
66
+ reads: "reads";
67
+ references: "references";
68
+ returns: "returns";
69
+ throws: "throws";
70
+ type: "type";
71
+ uses: "uses";
72
+ writes: "writes";
73
+ }>>>>;
74
+ }, z.core.$strict>, z.ZodTransform<{
75
+ source: import("./source").BundleSource;
76
+ reporter: import("../scanner").Reporter;
77
+ request: {
78
+ target: string;
79
+ filter: NodeFilter;
80
+ references: {
81
+ direction: "both" | "in" | "out";
82
+ kinds: readonly ("affects" | "depends" | "extends" | "mentions" | "names" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[];
83
+ };
84
+ };
85
+ }, {
86
+ onWarning?: import("./options").WarningHandler | undefined;
87
+ kinds?: readonly ("agent" | "api" | "asset" | "catalog" | "class" | "database" | "decision" | "decisions" | "definition" | "document" | "enum" | "field" | "folder" | "function" | "glossary" | "hook" | "interface" | "json" | "method" | "namespace" | "operation" | "parameter" | "phase" | "plan" | "query" | "reference" | "schema" | "section" | "skill" | "source" | "struct" | "table" | "task" | "term" | "trait" | "type")[] | undefined;
88
+ section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
89
+ repo?: string | undefined;
90
+ skillDirs?: readonly string[] | undefined;
91
+ docDirs?: readonly string[] | undefined;
92
+ excludes?: readonly string[] | undefined;
93
+ embeddings?: boolean | undefined;
94
+ from?: string | undefined;
95
+ cache?: boolean | undefined;
96
+ target: string;
97
+ incoming?: boolean | undefined;
98
+ outgoing?: boolean | undefined;
99
+ edges?: readonly ("affects" | "depends" | "extends" | "mentions" | "names" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[] | undefined;
100
+ }>>;
101
+ /** Options of `refs`: the node, which links to follow, and the bundle to read. */
102
+ export type RefsOptions = z.input<typeof refsSchema>;
103
+ /** One `refs` on a loaded bundle. */
104
+ export interface RefsRequest {
105
+ /** Id, path or name of the node. */
106
+ readonly target: string;
107
+ readonly filter: NodeFilter;
108
+ readonly references: ReferenceOptions;
109
+ }
110
+ /** What `refs` finds. The CLI prints it with `refs --json`. */
111
+ export interface RefsResult extends References {
112
+ /** The node the references are of. */
113
+ readonly node: NodeSummary;
114
+ }
115
+ /**
116
+ * Lists the references of one node of a loaded bundle.
117
+ *
118
+ * @param request - The node, the filter that narrows a name, and the references to keep.
119
+ * @returns The node with what it links to and what links to it.
120
+ * @throws {QueryError} When no node fits the target, or several do.
121
+ */
122
+ export declare function refsIn(retriever: Retriever, request: RefsRequest): RefsResult;
123
+ /**
124
+ * Lists what a node links to and what links to it.
125
+ *
126
+ * @param options - The node, which links to follow, and the repository or site to read.
127
+ * @returns The node with its references.
128
+ * @throws {OptionsError} When the options are not valid.
129
+ * @throws {SourceError} When the repository or the site cannot be read.
130
+ * @throws {QueryError} When no node fits the target, or several do.
131
+ */
132
+ export declare function refs(options: RefsOptions): Promise<RefsResult>;
133
+ export {};