@g3nomaly/analyze 0.1.0 → 0.1.2

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 (97) hide show
  1. package/README.md +10 -5
  2. package/dist/api/bundle-builder.d.ts +29 -10
  3. package/dist/api/bundle-cache.d.ts +7 -4
  4. package/dist/api/bundle-loader.d.ts +10 -3
  5. package/dist/api/create-docs.d.ts +33 -14
  6. package/dist/api/embedding.d.ts +16 -7
  7. package/dist/api/errors.d.ts +13 -6
  8. package/dist/api/list.d.ts +20 -20
  9. package/dist/api/options.d.ts +18 -22
  10. package/dist/api/refs.d.ts +24 -21
  11. package/dist/api/scan.d.ts +24 -12
  12. package/dist/api/search.d.ts +27 -21
  13. package/dist/api/services.d.ts +9 -1
  14. package/dist/api/show.d.ts +15 -19
  15. package/dist/api/site-reader.d.ts +11 -3
  16. package/dist/api/site-writer.d.ts +30 -7
  17. package/dist/api/source.d.ts +23 -12
  18. package/dist/api/target.d.ts +2 -0
  19. package/dist/cli.js +670 -238
  20. package/dist/embeddings/index-builder.d.ts +3 -1
  21. package/dist/embeddings/model.d.ts +26 -13
  22. package/dist/embeddings/searcher.d.ts +24 -7
  23. package/dist/embeddings/vectors.d.ts +3 -1
  24. package/dist/embeddings/words.d.ts +7 -3
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +647 -229
  27. package/dist/model/index.d.ts +416 -188
  28. package/dist/model/registry.d.ts +204 -11
  29. package/dist/query/graph.d.ts +83 -26
  30. package/dist/query/name-search.d.ts +39 -21
  31. package/dist/query/semantic.d.ts +11 -3
  32. package/dist/retrieval/describe.d.ts +11 -4
  33. package/dist/retrieval/filter.d.ts +27 -8
  34. package/dist/retrieval/index.d.ts +1 -1
  35. package/dist/retrieval/markdown.d.ts +3 -2
  36. package/dist/retrieval/report.d.ts +147 -70
  37. package/dist/retrieval/resolve.d.ts +11 -7
  38. package/dist/retrieval/retriever.d.ts +34 -23
  39. package/dist/retrieval/summary.d.ts +6 -3
  40. package/dist/scanner/code/doc/clean.d.ts +31 -5
  41. package/dist/scanner/code/doc/index.d.ts +7 -1
  42. package/dist/scanner/code/doc/markdown.d.ts +6 -1
  43. package/dist/scanner/code/doc/python.d.ts +6 -1
  44. package/dist/scanner/code/doc/tagged.d.ts +13 -4
  45. package/dist/scanner/code/doc/types.d.ts +16 -5
  46. package/dist/scanner/code/doc/xml.d.ts +6 -1
  47. package/dist/scanner/code/example.d.ts +31 -10
  48. package/dist/scanner/code/extract.d.ts +56 -21
  49. package/dist/scanner/code/grammar.d.ts +20 -5
  50. package/dist/scanner/code/language.d.ts +100 -66
  51. package/dist/scanner/code/languages/index.d.ts +21 -7
  52. package/dist/scanner/code/languages/shared.d.ts +23 -4
  53. package/dist/scanner/code/planner.d.ts +50 -14
  54. package/dist/scanner/code/symbols.d.ts +86 -20
  55. package/dist/scanner/code/types.d.ts +48 -15
  56. package/dist/scanner/config.d.ts +42 -0
  57. package/dist/scanner/content.d.ts +49 -14
  58. package/dist/scanner/decisions/parse.d.ts +20 -11
  59. package/dist/scanner/decisions/planner.d.ts +20 -8
  60. package/dist/scanner/docs.d.ts +36 -19
  61. package/dist/scanner/files.d.ts +44 -19
  62. package/dist/scanner/glossary/parse.d.ts +17 -7
  63. package/dist/scanner/glossary/planner.d.ts +15 -8
  64. package/dist/scanner/glossary/terms.d.ts +57 -27
  65. package/dist/scanner/graph/builder.d.ts +80 -21
  66. package/dist/scanner/highlight.d.ts +32 -9
  67. package/dist/scanner/ignore.d.ts +25 -0
  68. package/dist/scanner/index.d.ts +5 -2
  69. package/dist/scanner/markdown/frontmatter.d.ts +18 -3
  70. package/dist/scanner/markdown/links.d.ts +19 -9
  71. package/dist/scanner/markdown/outline.d.ts +13 -5
  72. package/dist/scanner/markdown/renderer.d.ts +32 -13
  73. package/dist/scanner/openapi/planner.d.ts +20 -8
  74. package/dist/scanner/packages.d.ts +28 -0
  75. package/dist/scanner/reporter.d.ts +5 -2
  76. package/dist/scanner/scanner.d.ts +21 -7
  77. package/dist/scanner/schema/definitions.d.ts +18 -8
  78. package/dist/scanner/schema/describe.d.ts +44 -18
  79. package/dist/scanner/schema/planner.d.ts +6 -3
  80. package/dist/scanner/schema/registry.d.ts +23 -16
  81. package/dist/scanner/skills/classify.d.ts +2 -1
  82. package/dist/scanner/skills/layout.d.ts +27 -9
  83. package/dist/scanner/skills/planner.d.ts +19 -4
  84. package/dist/scanner/specs.d.ts +8 -2
  85. package/dist/scanner/sql/catalog.d.ts +21 -7
  86. package/dist/scanner/sql/cursor.d.ts +9 -4
  87. package/dist/scanner/sql/database.d.ts +6 -3
  88. package/dist/scanner/sql/parse.d.ts +62 -27
  89. package/dist/scanner/sql/planner.d.ts +6 -2
  90. package/dist/scanner/sql/query.d.ts +34 -21
  91. package/dist/scanner/sql/registry.d.ts +24 -10
  92. package/dist/scanner/sql/source.d.ts +1 -0
  93. package/dist/scanner/sql/statements.d.ts +9 -3
  94. package/dist/scanner/sql/tokens.d.ts +25 -12
  95. package/dist/scanner/tasks/layout.d.ts +22 -10
  96. package/dist/scanner/tasks/planner.d.ts +64 -9
  97. package/package.json +2 -2
package/README.md CHANGED
@@ -11,7 +11,11 @@ cd ~/code/my-repo
11
11
  bunx @g3nomaly/analyze create_docs
12
12
  ```
13
13
 
14
- This writes `analyze_out/index.html` in the repository. `analyze_out/` is the only place analyze writes, and the query commands keep their scan cache there as well. Add it to `.gitignore`. Nothing else in the repository is changed.
14
+ This writes `analyze_out/index.html` in the repository, and the query commands keep their scan cache in `analyze_out/` as well. Add it to `.gitignore`. The one other file analyze writes is `.analyzeignore`, once, when the repository has none.
15
+
16
+ ## What it skips
17
+
18
+ `.analyzeignore` at the repository root lists what the scan skips, on top of `.gitignore`, with the same patterns: `name/` skips a directory anywhere, `/name` only at the root, `*.ext` a file anywhere. analyze creates it with `node_modules/`, `dist/`, `build/`, `out/`, `target/`, `vendor/`, `coverage/`, `data/` and the like when it is absent. Edit it to change what is skipped. `--exclude` adds patterns for one run.
15
19
 
16
20
  `analyze` needs [Bun](https://bun.sh) 1.2.21 or newer.
17
21
 
@@ -19,11 +23,12 @@ This writes `analyze_out/index.html` in the repository. `analyze_out/` is the on
19
23
 
20
24
  | Section | Read from |
21
25
  |---|---|
22
- | Skills | Every `SKILL.md` and the files beside it |
23
- | Docs | Markdown, JSON, OpenAPI documents and JSON Schemas. `glossary.md` is read as terms, `decisions.md` as decisions |
24
- | Code | Classes and functions in 13 languages through tree-sitter, with their doc comments |
26
+ | Skills | Every `SKILL.md` inside the directory of an AI tool (`.claude`, `.codex`, `.cursor`, `.gemini`, `.agents`, `.windsurf`, `.opencode`) and the files beside it. A `SKILL.md` elsewhere is a doc |
27
+ | Docs | Markdown. `glossary.md` is read as terms, `decisions.md` as decisions |
28
+ | Code | Classes and functions in 13 languages through tree-sitter, with their doc comments. JSON, TOML and YAML files, OpenAPI documents and JSON Schemas among them |
25
29
  | Database | `.sql` files. A file that creates tables becomes a schema diagram, any other a query catalog. No database is ever opened |
26
30
  | Tasks | The plans, phases and tasks that task-manager keeps, in `skills.settings.filetreeRoot` of `.g3n.config.json` (default `docs/task-manager`) |
31
+ | Packages | A directory with a `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `pom.xml`, `build.gradle`, `composer.json`, `.csproj`, `.gemspec` or `Gemfile` is shown as a package: an app, a library or a workspace |
27
32
 
28
33
  Every page, entry, parameter and field is a node of one graph. Edges connect a type to where it is used, a term to the text that uses it, a decision to the code it affects, a table to its foreign keys and queries, and a task to the code, docs and decisions it names and to the tasks it depends on. One registry in `src/model/registry.ts` defines every kind of node and edge.
29
34
 
@@ -69,4 +74,4 @@ The web primitives in `src/web/components/shadcn/` are installed with the `g3nui
69
74
 
70
75
  ## License
71
76
 
72
- Elastic License 2.0. The word embedding table in `data/embedding/` was computed from all-MiniLM-L6-v2 (Apache-2.0) and potion (MIT). Its notice and licenses are kept beside it.
77
+ Elastic License 2.0. The word embedding table in `assets/embedding/` was computed from all-MiniLM-L6-v2 (Apache-2.0) and potion (MIT). Its notice and licenses are kept beside it.
@@ -2,27 +2,38 @@ import type { DocsBundle } from '../model';
2
2
  import { type FileLister, type Reporter, type RepositoryScanner, type Source, type TaskTreeSource } from '../scanner';
3
3
  import type { SemanticIndexer } from './embedding';
4
4
  import type { ScanOptions } from './scan';
5
- /** What a `BundleBuilder` works with. */
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
+ */
6
14
  export interface BundleBuilderServices {
7
15
  readonly files: FileLister;
8
16
  readonly scanner: RepositoryScanner;
9
- /** Embeds the nodes for search by meaning. `null` leaves that search out of the bundle. */
10
17
  readonly semantic: SemanticIndexer | null;
11
- /** Recorded in the bundle as the tool that produced it. */
12
18
  readonly generator: string;
13
- /** Receives the problems that do not stop a scan, such as a config file that is not valid. */
14
19
  readonly reporter: Reporter;
15
20
  }
16
- /** The directories of one scan, per section. */
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
+ */
17
29
  export interface ScanSources {
18
30
  readonly skills: readonly Source[];
19
31
  readonly docs: readonly Source[];
20
32
  readonly code: readonly Source[];
21
- /** The task-manager tree of the repository. Empty when the repository has none. */
22
33
  readonly tasks: readonly TaskTreeSource[];
23
34
  }
24
35
  /**
25
- * Scans a repository into a bundle, with the file lister, scanner and embedder it holds.
36
+ * @brief Scans a repository into a bundle, with the file lister, scanner and embedder it holds.
26
37
  *
27
38
  * `createBuilder` in `src/api/services.ts` creates one per scan. `createDocs` writes its bundle into a site,
28
39
  * and `ScanLoader` hands it to the query functions. Both first call `sources` to list the files of the scan,
@@ -34,7 +45,11 @@ export interface ScanSources {
34
45
  */
35
46
  export declare class BundleBuilder {
36
47
  private readonly services;
37
- /** Creates a builder from the file lister, the scanner, the embedder and the reporter to use. */
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
+ */
38
53
  constructor(services: BundleBuilderServices);
39
54
  /**
40
55
  * Lists the files of a scan without reading them.
@@ -48,13 +63,16 @@ export declare class BundleBuilder {
48
63
  * Reads the files of a scan and links what they declare.
49
64
  *
50
65
  * @param sources - The directories of each section, from `sources`.
66
+ * @param title - Title of the bundle.
51
67
  * @returns The bundle, with a semantic index when the builder has an embedder.
52
68
  */
53
69
  build(sources: ScanSources, title: string): Promise<DocsBundle>;
54
70
  /**
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.
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.
57
74
  *
75
+ * @param repository - The repository to look in.
58
76
  * @returns One tree with the files below its directory, or none when the directory does not exist.
59
77
  */
60
78
  private tasksIn;
@@ -68,6 +86,7 @@ export declare class BundleBuilder {
68
86
  /**
69
87
  * Picks the directories one section is read from.
70
88
  *
89
+ * @param repository - The repository source, read when no directories are given.
71
90
  * @param directories - Absolute directories the caller passed. Empty means the repository.
72
91
  * @returns The repository, or one source per directory.
73
92
  */
@@ -19,15 +19,18 @@ export interface BundleCache {
19
19
  write(fingerprint: string, bundle: DocsBundle): Promise<void>;
20
20
  }
21
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.
22
+ * @brief Names the cache entry of a scan.
24
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.
25
28
  * @param generator - Name and version of the tool, such as `GENERATOR` in `src/api/services.ts`.
26
29
  * @returns A file-name-safe key.
27
30
  */
28
31
  export declare function cacheKey(scan: ScanOptions, generator: string): string;
29
32
  /**
30
- * Fingerprints the files of a scan by path, size and modification time, and
33
+ * @brief Fingerprints the files of a scan by path, size and modification time, and
31
34
  * the directory of its task tree. The fingerprint changes when a file is
32
35
  * added, removed or saved, and when the config moves the task tree.
33
36
  *
@@ -36,7 +39,7 @@ export declare function cacheKey(scan: ScanOptions, generator: string): string;
36
39
  */
37
40
  export declare function fingerprintOf(sources: ScanSources): Promise<string>;
38
41
  /**
39
- * Keeps a bundle in one file of a cache directory. The first line of the
42
+ * @brief Keeps a bundle in one file of a cache directory. The first line of the
40
43
  * file is the fingerprint, the rest is the bundle as JSON.
41
44
  *
42
45
  * `openRetriever` creates one per query that scans a repository, in
@@ -5,11 +5,15 @@ import { type BundleCache } from './bundle-cache';
5
5
  import type { ScanOptions } from './scan';
6
6
  /** Gets the bundle a query function reads. `loaderOf` in `src/api/source.ts` picks the implementation. */
7
7
  export interface BundleLoader {
8
- /** Loads the bundle to query. */
8
+ /**
9
+ * Loads the bundle to query.
10
+ *
11
+ * @returns The bundle the queries read.
12
+ */
9
13
  load(): Promise<DocsBundle>;
10
14
  }
11
15
  /**
12
- * Loads the bundle of a site that `createDocs` wrote, from the HTML file alone, without the repository the
16
+ * @brief Loads the bundle of a site that `createDocs` wrote, from the HTML file alone, without the repository the
13
17
  * site was written from. `loaderOf` in `src/api/source.ts` creates one when a caller passes `from`
14
18
  * (`--from` on the CLI); `openRetriever` loads it.
15
19
  */
@@ -26,12 +30,13 @@ export declare class SiteLoader implements BundleLoader {
26
30
  /**
27
31
  * Reads the HTML file and takes the bundle out of it. Warns when its embeddings are of another format.
28
32
  *
33
+ * @returns The bundle the site holds.
29
34
  * @throws {SourceError} When the file is missing or is no analyze site.
30
35
  */
31
36
  load(): Promise<DocsBundle>;
32
37
  }
33
38
  /**
34
- * Loads the bundle of a repository: from the cache when no file changed
39
+ * @brief Loads the bundle of a repository: from the cache when no file changed
35
40
  * since the last scan, else from a new scan, which it then keeps.
36
41
  *
37
42
  * `loaderOf` in `src/api/source.ts` creates one when a caller passes no `from`; `openRetriever` loads it.
@@ -44,6 +49,8 @@ export declare class ScanLoader implements BundleLoader {
44
49
  /**
45
50
  * Creates a loader for one repository.
46
51
  *
52
+ * @param builder - Builds the bundle when the cache has none.
53
+ * @param scan - The repository to scan.
47
54
  * @param cache - Keeps the bundle between runs. `null` scans every time.
48
55
  * @param reporter - Receives a warning when the cache cannot be written.
49
56
  */
@@ -1,4 +1,10 @@
1
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
+ */
2
8
  declare const createDocsSchema: z.ZodPipe<z.ZodObject<{
3
9
  onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
4
10
  repo: z.ZodOptional<z.ZodString>;
@@ -22,39 +28,52 @@ declare const createDocsSchema: z.ZodPipe<z.ZodObject<{
22
28
  }>>;
23
29
  /** Options of `createDocs`: what to scan and the title of the site. */
24
30
  export type CreateDocsOptions = z.input<typeof createDocsSchema>;
25
- /** Where `createDocs` wrote the site and what the site holds. */
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
+ */
26
56
  export interface CreateDocsResult {
27
- /** Absolute path of the site: `analyze_out/index.html` in the repository. */
28
57
  readonly out: string;
29
58
  readonly bytes: number;
30
59
  readonly skills: number;
31
60
  readonly docs: number;
32
61
  readonly files: number;
62
+ readonly configs: number;
63
+ readonly packages: Readonly<Record<PackageRole, number>>;
33
64
  readonly symbols: number;
34
- /** Glossary terms. */
35
65
  readonly terms: number;
36
66
  readonly decisions: number;
37
- /** Operations of OpenAPI documents. */
38
67
  readonly operations: number;
39
- /** Definitions of JSON Schemas and of OpenAPI documents. */
40
68
  readonly definitions: number;
41
- /** SQL files that create tables. */
42
69
  readonly schemas: number;
43
- /** Tables of those files. */
44
70
  readonly tables: number;
45
- /** Directories of SQL files that create no table. */
46
71
  readonly catalogs: number;
47
- /** Queries and statements of those directories. */
48
72
  readonly queries: number;
49
- /** Plans of the task tree. */
50
73
  readonly plans: number;
51
- /** Tasks of the task tree. */
52
74
  readonly tasks: number;
53
- /** Tasks with the status `completed`. */
54
75
  readonly completedTasks: number;
55
- /** Links between nodes: type references, mentions and the like. */
56
76
  readonly links: number;
57
- /** Nodes that search by meaning can find, and the model that embedded them. `null` without embeddings. */
58
77
  readonly embedded: {
59
78
  readonly nodes: number;
60
79
  readonly model: string;
@@ -4,17 +4,17 @@ export interface SemanticIndexer {
4
4
  /**
5
5
  * Embeds the searchable nodes of a scan.
6
6
  *
7
+ * @param nodes - Nodes of the scan to embed.
7
8
  * @returns The index for `DocsBundle.semantic`.
8
9
  */
9
10
  index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
10
11
  }
11
12
  /**
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.
13
+ * @brief Embeds nodes with the model that ships with the package.
15
14
  *
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`.
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
18
  */
19
19
  export declare class ShippedModelIndexer implements SemanticIndexer {
20
20
  private readonly baseDir;
@@ -25,8 +25,17 @@ export declare class ShippedModelIndexer implements SemanticIndexer {
25
25
  * @param baseDir - Absolute directory that relative paths of the bundled model files resolve against.
26
26
  */
27
27
  constructor(baseDir: string);
28
- /** Reads the model on the first call, then embeds the searchable nodes into an index for `DocsBundle.semantic`. */
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
+ */
29
34
  index(nodes: readonly GraphNode[]): Promise<SemanticIndex>;
30
- /** Reads the two files of the model and unpacks the four-bit vectors into a word table. */
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
+ */
31
40
  private load;
32
41
  }
@@ -1,6 +1,9 @@
1
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.
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"])`.
4
7
  */
5
8
  export declare class OptionsError extends Error {
6
9
  readonly issues: readonly string[];
@@ -13,15 +16,19 @@ export declare class OptionsError extends Error {
13
16
  constructor(issues: readonly string[]);
14
17
  }
15
18
  /**
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.
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".')`.
18
23
  */
19
24
  export declare class QueryError extends Error {
20
25
  readonly name = "QueryError";
21
26
  }
22
27
  /**
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.
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')`.
25
32
  */
26
33
  export declare class SourceError extends Error {
27
34
  readonly name = "SourceError";
@@ -1,38 +1,29 @@
1
1
  import { z } from 'zod';
2
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
+ */
3
8
  declare const listSchema: z.ZodPipe<z.ZodObject<{
4
9
  onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
5
10
  kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
6
- agent: "agent";
7
- api: "api";
8
- asset: "asset";
9
- catalog: "catalog";
10
11
  class: "class";
11
- database: "database";
12
12
  decision: "decision";
13
- decisions: "decisions";
14
13
  definition: "definition";
15
- document: "document";
16
14
  enum: "enum";
17
15
  field: "field";
16
+ file: "file";
18
17
  folder: "folder";
19
18
  function: "function";
20
- glossary: "glossary";
21
- hook: "hook";
22
19
  interface: "interface";
23
- json: "json";
24
- method: "method";
25
20
  namespace: "namespace";
26
21
  operation: "operation";
22
+ package: "package";
27
23
  parameter: "parameter";
28
24
  phase: "phase";
29
25
  plan: "plan";
30
26
  query: "query";
31
- reference: "reference";
32
- schema: "schema";
33
- section: "section";
34
- skill: "skill";
35
- source: "source";
36
27
  struct: "struct";
37
28
  table: "table";
38
29
  task: "task";
@@ -64,7 +55,7 @@ declare const listSchema: z.ZodPipe<z.ZodObject<{
64
55
  };
65
56
  }, {
66
57
  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;
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;
68
59
  section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
69
60
  repo?: string | undefined;
70
61
  skillDirs?: readonly string[] | undefined;
@@ -77,19 +68,28 @@ declare const listSchema: z.ZodPipe<z.ZodObject<{
77
68
  }>>;
78
69
  /** Options of `list`: the filter, the limit, and the bundle to list. */
79
70
  export type ListOptions = z.input<typeof listSchema>;
80
- /** One `list` on a loaded bundle. */
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
+ */
81
77
  export interface ListRequest {
82
78
  readonly filter: NodeFilter;
83
- /** Most rows. `null` lists everything. */
84
79
  readonly limit: number | null;
85
80
  }
86
- /** What `list` finds. The CLI prints it with `list --json`. */
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
+ */
87
86
  export interface ListResult {
88
87
  readonly nodes: readonly NodeSummary[];
89
88
  }
90
89
  /**
91
90
  * Lists the pages and entries of a loaded bundle.
92
91
  *
92
+ * @param retriever - The loaded bundle to list.
93
93
  * @param request - The filter and the limit.
94
94
  * @returns The nodes, in the order of the navigation.
95
95
  */
@@ -7,40 +7,30 @@ export type WarningHandler = (message: string) => void;
7
7
  export declare const warningShape: {
8
8
  onWarning: z.ZodOptional<z.ZodCustom<WarningHandler, WarningHandler>>;
9
9
  };
10
- /** The options that narrow the nodes a query looks at. */
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
+ */
11
16
  export declare const filterShape: {
12
- /** Only nodes of these kinds. Empty or absent keeps every kind. */
13
17
  kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
14
- agent: "agent";
15
- api: "api";
16
- asset: "asset";
17
- catalog: "catalog";
18
18
  class: "class";
19
- database: "database";
20
19
  decision: "decision";
21
- decisions: "decisions";
22
20
  definition: "definition";
23
- document: "document";
24
21
  enum: "enum";
25
22
  field: "field";
23
+ file: "file";
26
24
  folder: "folder";
27
25
  function: "function";
28
- glossary: "glossary";
29
- hook: "hook";
30
26
  interface: "interface";
31
- json: "json";
32
- method: "method";
33
27
  namespace: "namespace";
34
28
  operation: "operation";
29
+ package: "package";
35
30
  parameter: "parameter";
36
31
  phase: "phase";
37
32
  plan: "plan";
38
33
  query: "query";
39
- reference: "reference";
40
- schema: "schema";
41
- section: "section";
42
- skill: "skill";
43
- source: "source";
44
34
  struct: "struct";
45
35
  table: "table";
46
36
  task: "task";
@@ -48,7 +38,6 @@ export declare const filterShape: {
48
38
  trait: "trait";
49
39
  type: "type";
50
40
  }>>>>;
51
- /** Only nodes of this section. */
52
41
  section: z.ZodOptional<z.ZodEnum<{
53
42
  code: "code";
54
43
  database: "database";
@@ -57,20 +46,27 @@ export declare const filterShape: {
57
46
  tasks: "tasks";
58
47
  }>>;
59
48
  };
60
- /** The filter options after validation. */
49
+ /** The filter options after validation: `kinds` and `section`, both optional. */
61
50
  type FilterFields = z.output<z.ZodObject<typeof filterShape>>;
62
51
  /**
63
52
  * Turns validated filter options into the filter the retriever takes.
64
53
  *
65
- * @returns The filter. Absent options keep every node.
54
+ * @param fields - Validated filter options, from `filterShape`.
55
+ * @returns The filter the retriever takes. Absent options keep every node.
66
56
  */
67
57
  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. */
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
+ */
69
64
  export declare function reporterOf(onWarning: WarningHandler | undefined): Reporter;
70
65
  /**
71
66
  * Validates the options a caller passed against the schema of a function.
72
67
  *
73
68
  * @param schema - The schema of the options, with its transform.
69
+ * @param input - The options the caller passed, not yet validated.
74
70
  * @returns The options after the transform.
75
71
  * @throws {OptionsError} When the options do not fit the schema. Its `issues` name each problem.
76
72
  */
@@ -1,38 +1,32 @@
1
1
  import { z } from 'zod';
2
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
+ */
3
11
  declare const refsSchema: z.ZodPipe<z.ZodObject<{
4
12
  onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
5
13
  kinds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
6
- agent: "agent";
7
- api: "api";
8
- asset: "asset";
9
- catalog: "catalog";
10
14
  class: "class";
11
- database: "database";
12
15
  decision: "decision";
13
- decisions: "decisions";
14
16
  definition: "definition";
15
- document: "document";
16
17
  enum: "enum";
17
18
  field: "field";
19
+ file: "file";
18
20
  folder: "folder";
19
21
  function: "function";
20
- glossary: "glossary";
21
- hook: "hook";
22
22
  interface: "interface";
23
- json: "json";
24
- method: "method";
25
23
  namespace: "namespace";
26
24
  operation: "operation";
25
+ package: "package";
27
26
  parameter: "parameter";
28
27
  phase: "phase";
29
28
  plan: "plan";
30
29
  query: "query";
31
- reference: "reference";
32
- schema: "schema";
33
- section: "section";
34
- skill: "skill";
35
- source: "source";
36
30
  struct: "struct";
37
31
  table: "table";
38
32
  task: "task";
@@ -84,7 +78,7 @@ declare const refsSchema: z.ZodPipe<z.ZodObject<{
84
78
  };
85
79
  }, {
86
80
  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;
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;
88
82
  section?: "code" | "database" | "docs" | "skills" | "tasks" | undefined;
89
83
  repo?: string | undefined;
90
84
  skillDirs?: readonly string[] | undefined;
@@ -100,21 +94,30 @@ declare const refsSchema: z.ZodPipe<z.ZodObject<{
100
94
  }>>;
101
95
  /** Options of `refs`: the node, which links to follow, and the bundle to read. */
102
96
  export type RefsOptions = z.input<typeof refsSchema>;
103
- /** One `refs` on a loaded bundle. */
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
104
  export interface RefsRequest {
105
- /** Id, path or name of the node. */
106
105
  readonly target: string;
107
106
  readonly filter: NodeFilter;
108
107
  readonly references: ReferenceOptions;
109
108
  }
110
- /** What `refs` finds. The CLI prints it with `refs --json`. */
109
+ /**
110
+ * What `refs` finds. The CLI prints it with `refs --json`.
111
+ *
112
+ * @property node - The node the references are of.
113
+ */
111
114
  export interface RefsResult extends References {
112
- /** The node the references are of. */
113
115
  readonly node: NodeSummary;
114
116
  }
115
117
  /**
116
118
  * Lists the references of one node of a loaded bundle.
117
119
  *
120
+ * @param retriever - The loaded bundle to read.
118
121
  * @param request - The node, the filter that narrows a name, and the references to keep.
119
122
  * @returns The node with what it links to and what links to it.
120
123
  * @throws {QueryError} When no node fits the target, or several do.