@g3nomaly/analyze 0.1.0 → 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.
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
@@ -1,66 +1,84 @@
1
1
  import type { EdgeKind, LinkedText, NodeRef } from '../../model';
2
2
  import type { GraphBuilder } from '../graph/builder';
3
- /** Where a type name is used. Decides which declaration it means. */
3
+ /**
4
+ * @brief Where a type name is used. Decides which declaration it means.
5
+ *
6
+ * @property path - Display path of the file the name is in. `null` for a name in prose, which has no file of its own.
7
+ * @property family - Language family of the name. `null` matches every language.
8
+ * @property typeParameters - Type parameters in scope, such as `T`. They are never linked.
9
+ */
4
10
  export interface TypeScope {
5
- /** Display path of the file the name is in. `null` for a name in prose, which has no file of its own. */
6
11
  readonly path: string | null;
7
- /** Language family of the name. `null` matches every language. */
8
12
  readonly family: string | null;
9
- /** Type parameters in scope, such as `T`. They are never linked. */
10
13
  readonly typeParameters: ReadonlySet<string>;
11
14
  }
12
15
  /** Scope of a name in a document: any language, no file. */
13
16
  export declare const PROSE_SCOPE: TypeScope;
14
17
  /**
15
- * Every class, interface, struct, enum, trait and type alias of the scan, by name.
18
+ * @brief Every class, interface, struct, enum, trait and type alias of the scan, by name.
16
19
  *
17
20
  * Holds every declaration of each name. Created per scan by `RepositoryScanner` in
18
21
  * `scanner/scanner.ts`; `SymbolPlanner` in `symbols.ts` registers each type it adds,
19
- * and {@link TypeLinker} resolves names against it.
22
+ * and {@link TypeLinker} resolves names against it. Created with `new TypeIndex()`.
23
+ *
24
+ * @property byName - Declarations of each name.
20
25
  */
21
26
  export declare class TypeIndex {
22
27
  private readonly byName;
23
28
  /**
24
- * Adds a type declaration under its name.
29
+ * @brief Adds a type declaration under its name.
25
30
  *
31
+ * @param name - Name the type is declared with.
32
+ * @param ref - Node of the declaration.
26
33
  * @param path - Display path of the file that declares it.
27
34
  * @param family - Language family of that file, from `familyOf`.
28
35
  */
29
36
  register(name: string, ref: NodeRef, path: string, family: string): void;
30
37
  /**
31
- * The declaration a name refers to, or `null` when there is none or the name is ambiguous.
38
+ * @brief The declaration a name refers to, or `null` when there is none or the name is ambiguous.
39
+ *
32
40
  * A declaration in the same file wins, then the one whose directory is closest.
41
+ *
42
+ * @param name - Identifier to resolve.
43
+ * @param scope - Where the name is used.
44
+ * @returns The node of the declaration, or `null`.
33
45
  */
34
46
  resolve(name: string, scope: TypeScope): NodeRef | null;
35
47
  }
36
48
  /**
37
- * Every function and method of the scan, by name and by `Owner.name`. Lets
49
+ * @brief Every function and method of the scan, by name and by `Owner.name`. Lets
38
50
  * prose refer to a function the way it refers to a type.
39
51
  *
40
52
  * Holds every declaration of each key. Created per scan by `RepositoryScanner` in
41
53
  * `scanner/scanner.ts`; `SymbolPlanner` in `symbols.ts` registers each function and
42
54
  * method it adds, and {@link TypeLinker.mention} resolves inline code against it.
55
+ * Created with `new CallableIndex()`.
56
+ *
57
+ * @property byName - Declarations of each key: the name, and `Owner.name` for a method.
43
58
  */
44
59
  export declare class CallableIndex {
45
60
  private readonly byName;
46
61
  /**
47
- * Adds a function or method under its name and, when it has an owner, under `Owner.name`.
62
+ * @brief Adds a function or method under its name and, when it has an owner, under `Owner.name`.
48
63
  *
64
+ * @param name - Name the function is declared with.
49
65
  * @param owner - Name of the type or namespace it is declared in, or `null`.
66
+ * @param ref - Node of the declaration.
50
67
  * @param path - Display path of its file.
51
68
  * @param family - Language family of its file, from `familyOf`.
52
69
  */
53
70
  register(name: string, owner: string | null, ref: NodeRef, path: string, family: string): void;
54
71
  /**
55
- * The function a piece of inline code names.
72
+ * @brief The function a piece of inline code names.
56
73
  *
57
74
  * @param text - Inline code, such as `choose_route()` or `Invoice.add`.
75
+ * @param scope - Where the code is used.
58
76
  * @returns The function, or `null` when the text names none or more than one.
59
77
  */
60
78
  resolve(text: string, scope: TypeScope): NodeRef | null;
61
79
  }
62
80
  /**
63
- * Turns type names in source text into links between nodes, and records each link as an edge.
81
+ * @brief Turns type names in source text into links between nodes, and records each link as an edge.
64
82
  *
65
83
  * Holds the type and callable indexes it resolves names against and the graph it adds
66
84
  * edges to. Created per scan by `RepositoryScanner` in `scanner/scanner.ts`; used by
@@ -75,18 +93,33 @@ export declare class TypeLinker {
75
93
  private readonly index;
76
94
  private readonly callables;
77
95
  private readonly graph;
78
- /** Takes the indexes it resolves names against and the graph it adds edges to. */
96
+ /**
97
+ * Takes the indexes it resolves names against and the graph it adds edges to.
98
+ *
99
+ * @param index - Type declarations the names resolve against.
100
+ * @param callables - Functions and methods the inline code resolves against.
101
+ * @param graph - Graph the edges are added to.
102
+ */
79
103
  constructor(index: TypeIndex, callables: CallableIndex, graph: GraphBuilder);
80
104
  /**
81
- * Links every known type name in `text`, such as `Booking` in `Promise<Booking>`.
105
+ * @brief Links every known type name in `text`, such as `Booking` in `Promise<Booking>`.
106
+ *
82
107
  * Records one `relation` edge from `from` to each type it finds.
108
+ *
109
+ * @param text - Source text to scan for names.
110
+ * @param from - Node the text belongs to. The edges start here.
111
+ * @param relation - Kind of edge to record.
112
+ * @param scope - Where the names are used.
113
+ * @returns The text with the links to the types it names.
83
114
  */
84
115
  link(text: string, from: NodeRef, relation: EdgeKind, scope: TypeScope): LinkedText;
85
116
  /**
86
- * The type or function that inline code names, and an edge to it.
117
+ * @brief The type or function that inline code names, and an edge to it.
87
118
  *
88
119
  * @param text - Inline code, such as `Booking` or `choose_route()`.
89
120
  * @param from - Node the code is written in. The edge starts here.
121
+ * @param scope - Where the code is used.
122
+ * @param relation - Kind of edge to record, `mentions` by default.
90
123
  * @returns The node the code names, or `null` when it names none, more than one, or `from` itself.
91
124
  */
92
125
  mention(text: string, from: NodeRef, scope: TypeScope, relation?: EdgeKind): NodeRef | null;
@@ -0,0 +1,42 @@
1
+ import type { NodeRef } from '../model';
2
+ import type { FileRenderer } from './content';
3
+ import type { Source } from './files';
4
+ import type { GraphBuilder } from './graph/builder';
5
+ import type { ProseResolvers } from './markdown/links';
6
+ import type { SpecPlanner } from './specs';
7
+ /**
8
+ * @brief Adds the JSON, TOML and YAML files of the code section to the graph, in the folders they are in.
9
+ *
10
+ * A file that is an OpenAPI document or a JSON Schema goes to the `SpecPlanner`, which adds its
11
+ * operations and definitions. Every other file becomes a page that shows it as it is. Created by
12
+ * `RepositoryScanner` for every scan and handed to `CodePlanner`, which calls `planFile` for each
13
+ * file `handles` accepts, in the same pass as the source files so the tree stays in path order.
14
+ *
15
+ * @example
16
+ * const configs = new ConfigPlanner(graph, files, resolvers, specs);
17
+ * if (configs.handles(path)) await configs.planFile(section, source, path);
18
+ */
19
+ export declare class ConfigPlanner {
20
+ private readonly graph;
21
+ private readonly files;
22
+ private readonly resolvers;
23
+ private readonly specs;
24
+ /**
25
+ * @brief Keeps the graph to add to, the renderer of plain files and the planner of specs.
26
+ *
27
+ * @param files - Renders a plain file to its page.
28
+ * @param resolvers - Resolves the links of each page.
29
+ * @param specs - Plans OpenAPI documents and JSON Schemas.
30
+ */
31
+ constructor(graph: GraphBuilder, files: FileRenderer, resolvers: ProseResolvers, specs: SpecPlanner);
32
+ /** Tells whether a file is a JSON, TOML or YAML file, by its extension. */
33
+ handles(path: string): boolean;
34
+ /**
35
+ * @brief Adds one JSON, TOML or YAML file below the folder of its directory: as a spec when it is one, else as a page.
36
+ *
37
+ * @param section - Node of the code section.
38
+ * @param source - Directory the file is in.
39
+ * @param path - Path of the file inside the source, accepted by `handles`.
40
+ */
41
+ planFile(section: NodeRef, { root, prefix }: Source, path: string): Promise<void>;
42
+ }
@@ -1,38 +1,73 @@
1
1
  import type { FileContent } from '../model';
2
2
  import type { CodeHighlighter } from './highlight';
3
3
  import type { LinkResolver, MarkdownRenderer } from './markdown/renderer';
4
- /** A file as its page shows it. */
4
+ /**
5
+ * @brief A file as its page shows it.
6
+ *
7
+ * @property title - Frontmatter `title` or `name`, else the first heading, else the file name.
8
+ * @property description - Frontmatter `description`, or `''`.
9
+ * @property content - What the page shows of the file: rendered markdown, highlighted text or an image.
10
+ */
5
11
  export interface RenderedFile {
6
- /** Frontmatter `title` or `name`, else the first heading, else the file name. */
7
12
  readonly title: string;
8
- /** Frontmatter `description`, or `''`. */
9
13
  readonly description: string;
10
14
  readonly content: FileContent;
11
15
  }
12
- /** Tells a markdown or MDX file by its extension. */
16
+ /**
17
+ * @brief Tells whether a file is markdown or MDX, by its extension.
18
+ *
19
+ * @param path - Path of the file.
20
+ * @returns `true` for a `.md`, `.markdown` or `.mdx` file.
21
+ */
13
22
  export declare function isMarkdown(path: string): boolean;
14
- /** Reads an image file into a `data:` URI, or returns `null` when it is no image, is missing or is too large. */
23
+ /**
24
+ * @brief Reads an image file into a `data:` URI.
25
+ *
26
+ * @param absolutePath - Absolute path of the image file.
27
+ * @returns The `data:` URI, or `null` when the file is no image, is missing, or is larger than `MAX_IMAGE_BYTES`.
28
+ */
15
29
  export declare function imageDataUri(absolutePath: string): Promise<string | null>;
16
30
  /**
17
- * Turns a file of any type into what its page shows: rendered markdown,
18
- * highlighted text or an image. Holds the markdown renderer and the code
19
- * highlighter it uses. Created by `RepositoryScanner`, and used by the
20
- * planners of the docs, skills, code, glossary, decisions, JSON Schema and
21
- * tasks sections.
31
+ * @brief Turns a file of any type into what its page shows: rendered markdown,
32
+ * highlighted text or an image.
33
+ *
34
+ * Holds the markdown renderer and the code highlighter it uses. Created by `RepositoryScanner`
35
+ * with `new FileRenderer(markdown, highlighter)`, and used by the planners of the docs, skills,
36
+ * code, glossary, decisions, JSON Schema and tasks sections.
22
37
  */
23
38
  export declare class FileRenderer {
24
39
  private readonly markdownRenderer;
25
40
  private readonly highlighter;
26
- /** Keeps the renderer and the highlighter for every file it renders. */
41
+ /**
42
+ * Keeps the renderer and the highlighter for every file it renders.
43
+ *
44
+ * @param markdownRenderer - Renders markdown to HTML and collects its headings.
45
+ * @param highlighter - Highlights text files by their language.
46
+ */
27
47
  constructor(markdownRenderer: MarkdownRenderer, highlighter: CodeHighlighter);
28
48
  /**
29
- * Reads a file and renders it by its type.
49
+ * @brief Reads a file and renders it by its type.
30
50
  *
51
+ * @param absolutePath - Absolute path of the file.
31
52
  * @param resolver - Rewrites the links of a markdown file.
53
+ * @returns The title, description and content of the file.
32
54
  */
33
55
  render(absolutePath: string, resolver?: LinkResolver): Promise<RenderedFile>;
34
- /** Renders markdown that is already read. `fallbackTitle` is used when the text names no title. */
56
+ /**
57
+ * @brief Renders markdown that is already read. `fallbackTitle` is used when the text names no title.
58
+ *
59
+ * @param source - Markdown source, with its frontmatter if it has any.
60
+ * @param fallbackTitle - Title used when neither the frontmatter nor the text names one.
61
+ * @param resolver - Rewrites the links of the markdown.
62
+ * @param mdx - Whether the source is MDX, whose `import` and `export` lines are removed first.
63
+ * @returns The title, description and content of the file.
64
+ */
35
65
  markdown(source: string, fallbackTitle: string, resolver?: LinkResolver, mdx?: boolean): Promise<RenderedFile>;
36
- /** Reads a file as text, highlighted by its extension when it is small enough, or omitted when it is large or binary. */
66
+ /**
67
+ * @brief Reads a file as text, highlighted by its extension when it is small enough, or omitted when it is large or binary.
68
+ *
69
+ * @param absolutePath - Absolute path of the file.
70
+ * @returns The highlighted text, or an `omitted` content with its reason and size.
71
+ */
37
72
  text(absolutePath: string): Promise<FileContent>;
38
73
  }
@@ -1,26 +1,35 @@
1
- /** One decision as the decision log writes it. */
1
+ /**
2
+ * @brief One decision as the decision log writes it.
3
+ *
4
+ * @property id - Number or id in front of the title, such as `3` or `ADR-0003`. `''` when the title has none.
5
+ * @property title - Title of the decision, without its id or date.
6
+ * @property status - As written, such as `accepted`. `''` when the decision states none.
7
+ * @property date - As written. `''` when the decision states none.
8
+ * @property body - Markdown of the decision without its heading, status line and date line.
9
+ */
2
10
  export interface ParsedDecision {
3
- /** Number or id in front of the title, such as `3` or `ADR-0003`. `''` when the title has none. */
4
11
  readonly id: string;
5
12
  readonly title: string;
6
- /** As written, such as `accepted`. `''` when the decision states none. */
7
13
  readonly status: string;
8
- /** As written. `''` when the decision states none. */
9
14
  readonly date: string;
10
- /** Markdown of the decision without its heading, status line and date line. */
11
15
  readonly body: string;
12
16
  }
13
- /** A decision log split into its intro and its decisions. */
17
+ /**
18
+ * @brief A decision log split into its intro and its decisions.
19
+ *
20
+ * @property intro - Markdown of everything in front of the first decision, with the title.
21
+ * @property decisions - The decisions in file order.
22
+ */
14
23
  export interface ParsedDecisions {
15
- /** Markdown of everything in front of the first decision, with the title. */
16
24
  readonly intro: string;
17
25
  readonly decisions: readonly ParsedDecision[];
18
26
  }
19
27
  /**
20
- * Reads the decisions of a decision log. Each heading of the highest level
21
- * below the title starts one decision. The heading may carry a number or a
22
- * date in front of the title. `Status:` and `Date:` lines at the top of a
23
- * decision become its status and date.
28
+ * @brief Reads the decisions of a decision log.
29
+ *
30
+ * Each heading of the highest level below the title starts one decision. The heading may carry a
31
+ * number or a date in front of the title. `Status:` and `Date:` lines at the top of a decision
32
+ * become its status and date.
24
33
  *
25
34
  * @param markdown - The decision log without frontmatter.
26
35
  * @returns The decisions in file order and the text in front of them.
@@ -5,25 +5,37 @@ import type { GraphBuilder } from '../graph/builder';
5
5
  import type { ProseResolvers } from '../markdown/links';
6
6
  import type { MarkdownRenderer } from '../markdown/renderer';
7
7
  /**
8
- * Adds a decision log to the graph: one node for the file and one `decision`
9
- * node per decision. Used by `DocPlanner` for every `decisions.md` of the docs
10
- * section. What a decision links to or names in inline code becomes an
11
- * `affects` edge from the decision.
8
+ * @brief Adds a decision log to the graph: one node for the file and one `decision`
9
+ * node per decision.
12
10
  *
13
- * Holds the graph, the file renderer, the markdown renderer and the prose
14
- * resolvers. Created by `RepositoryScanner`, which hands it to `DocPlanner`.
11
+ * Used by `DocPlanner` for every `decisions.md` of the docs section. What a decision links to or
12
+ * names in inline code becomes an `affects` edge from the decision.
13
+ *
14
+ * Holds the graph, the file renderer, the markdown renderer and the prose resolvers. Created by
15
+ * `RepositoryScanner`, which hands it to `DocPlanner`.
15
16
  */
16
17
  export declare class DecisionPlanner {
17
18
  private readonly graph;
18
19
  private readonly files;
19
20
  private readonly markdown;
20
21
  private readonly resolvers;
21
- /** Creates a planner. */
22
+ /**
23
+ * Creates a planner.
24
+ *
25
+ * @param graph - Graph the file and decision nodes are added to.
26
+ * @param files - Renders the text of the decision log around the decisions.
27
+ * @param markdown - Renders the body of each decision.
28
+ * @param resolvers - Resolves the links of the decision log and its decisions.
29
+ */
22
30
  constructor(graph: GraphBuilder, files: FileRenderer, markdown: MarkdownRenderer, resolvers: ProseResolvers);
23
31
  /**
24
- * Reads one decision log and adds its nodes.
32
+ * @brief Reads one decision log and adds its nodes.
25
33
  *
26
34
  * @param parent - Folder or section the file is in.
35
+ * @param root - Absolute directory `path` is relative to.
36
+ * @param path - Path of the file inside `root`.
37
+ * @param displayPath - Path the site shows.
38
+ * @param prefix - Prefix the bundle puts in front of paths from `root`.
27
39
  * @returns The node of the file.
28
40
  */
29
41
  plan(parent: NodeRef, { root, path, displayPath, prefix }: DocFile): Promise<NodeRef>;
@@ -5,32 +5,43 @@ import { type Source } from './files';
5
5
  import type { GlossaryPlanner } from './glossary/planner';
6
6
  import type { GraphBuilder } from './graph/builder';
7
7
  import type { ProseResolvers } from './markdown/links';
8
- import type { SpecPlanner } from './specs';
9
8
  /** What a file of the docs section becomes. */
10
- export type DocKind = 'document' | 'json' | 'glossary' | 'decisions';
11
- /** A file of the docs section, with the paths the planners need. */
9
+ export type DocKind = 'document' | 'glossary' | 'decisions';
10
+ /**
11
+ * @brief A file of the docs section, with the paths the planners need.
12
+ *
13
+ * @property root - Absolute directory `path` is relative to.
14
+ * @property path - Path of the file inside `root`.
15
+ * @property displayPath - Path the site shows: `path` behind the prefix of its source.
16
+ * @property prefix - Prefix the bundle puts in front of paths from `root`.
17
+ */
12
18
  export interface DocFile {
13
- /** Absolute directory `path` is relative to. */
14
19
  readonly root: string;
15
- /** Path of the file inside `root`. */
16
20
  readonly path: string;
17
- /** Path the site shows: `path` behind the prefix of its source. */
18
21
  readonly displayPath: string;
19
- /** Prefix the bundle puts in front of paths from `root`. */
20
22
  readonly prefix: string;
21
23
  }
22
24
  /**
23
- * Tells what a file of the docs section becomes, from its extension and name.
25
+ * @brief Tells what a file of the docs section becomes, from its extension and name.
24
26
  *
27
+ * @param path - Path of the file.
25
28
  * @returns The kind, or `null` for a file that does not belong in the docs section.
26
29
  */
27
30
  export declare function docKind(path: string): DocKind | null;
28
31
  /**
29
- * Adds the docs section to the graph: markdown and JSON files in the folders
30
- * they are in. A `glossary.md` and a `decisions.md` go to their own planners,
31
- * which add one node per term and per decision. A JSON or YAML file that is
32
- * an OpenAPI document or a JSON Schema goes to the `SpecPlanner`. Created by
33
- * `RepositoryScanner` for every scan.
32
+ * @brief Adds a file as a page of its own, rendered as it is, and registers its path so links can find it.
33
+ *
34
+ * @param kind - Node kind the file becomes, such as `document` or `json`.
35
+ * @param parent - Folder the page is added below.
36
+ * @param file - The file, with its root, path and display path.
37
+ * @returns Ref of the new page.
38
+ */
39
+ export declare function addFilePage(graph: GraphBuilder, files: FileRenderer, resolvers: ProseResolvers, kind: 'document' | 'json' | 'toml' | 'yaml', parent: NodeRef, { root, path, displayPath, prefix }: DocFile): NodeRef;
40
+ /**
41
+ * @brief Adds the docs section to the graph: the markdown files in the folders they are in.
42
+ *
43
+ * A `glossary.md` and a `decisions.md` go to their own planners, which add one node per term and
44
+ * per decision. Created by `RepositoryScanner` for every scan.
34
45
  */
35
46
  export declare class DocPlanner {
36
47
  private readonly graph;
@@ -38,15 +49,21 @@ export declare class DocPlanner {
38
49
  private readonly resolvers;
39
50
  private readonly glossaries;
40
51
  private readonly decisions;
41
- private readonly specs;
42
- /** Keeps the graph to add to and the renderer and planners each file goes to. */
43
- constructor(graph: GraphBuilder, files: FileRenderer, resolvers: ProseResolvers, glossaries: GlossaryPlanner, decisions: DecisionPlanner, specs: SpecPlanner);
44
52
  /**
45
- * Adds every doc file of the sources.
53
+ * @brief Keeps the graph to add to and the renderer and planners each file goes to.
54
+ *
55
+ * @param graph - Graph the page nodes are added to.
56
+ * @param files - Renders markdown files to their pages.
57
+ * @param resolvers - Resolves the links of each page.
58
+ * @param glossaries - Plans each `glossary.md`.
59
+ * @param decisions - Plans each `decisions.md`.
60
+ */
61
+ constructor(graph: GraphBuilder, files: FileRenderer, resolvers: ProseResolvers, glossaries: GlossaryPlanner, decisions: DecisionPlanner);
62
+ /**
63
+ * @brief Adds every doc file of the sources.
46
64
  *
47
65
  * @param section - Node of the docs section.
66
+ * @param sources - Directories whose files are read.
48
67
  */
49
68
  plan(section: NodeRef, sources: readonly Source[]): Promise<void>;
50
- /** Adds a markdown or JSON file as a page of its own and registers its path. */
51
- private planFile;
52
69
  }
@@ -1,60 +1,85 @@
1
1
  /** Directory at the root of a repository where analyze writes its site and its cache. */
2
2
  export declare const OUTPUT_DIR = "analyze_out";
3
- /** Directories and files skipped in every scan, on top of `.gitignore`. The output of analyze is one, so it never documents itself. */
4
- export declare const DEFAULT_EXCLUDES: readonly string[];
5
- /** A directory to read: its files, and the prefix their paths get in the bundle. */
3
+ /**
4
+ * @brief A directory to read: its files, and the prefix their paths get in the bundle.
5
+ *
6
+ * @property root - Absolute directory.
7
+ * @property files - Root-relative POSIX paths.
8
+ * @property prefix - Put in front of paths in the bundle. `''` for the repository, `name/` for a directory outside it.
9
+ * @property skillsAnywhere - Set for a directory the reader names as skills: a `SKILL.md` anywhere in it is a skill, not only inside an AI directory.
10
+ */
6
11
  export interface Source {
7
- /** Absolute directory. */
8
12
  readonly root: string;
9
- /** Root-relative POSIX paths. */
10
13
  readonly files: readonly string[];
11
- /** Put in front of paths in the bundle. `''` for the repository, `name/` for a directory outside it. */
12
14
  readonly prefix: string;
15
+ readonly skillsAnywhere?: boolean;
13
16
  }
14
17
  /** Lists the files of a directory tree. */
15
18
  export interface FileLister {
16
- /** Returns root-relative POSIX paths, sorted. */
19
+ /**
20
+ * @brief Lists the files below a directory.
21
+ *
22
+ * @param root - Absolute directory.
23
+ * @returns Root-relative POSIX paths, sorted.
24
+ */
17
25
  list(root: string): Promise<string[]>;
18
26
  }
19
27
  /**
20
- * Lists the files of a directory tree. Inside a git work tree it queries git, so
21
- * `.gitignore` applies. Elsewhere it walks the directory. Holds the globs it
22
- * skips: {@link DEFAULT_EXCLUDES} and the excludes it is created with.
23
- * Created in `api/services.ts` and used by `BundleBuilder` for every source.
28
+ * @brief Lists the files of a directory tree. Inside a git work tree it queries git, so
29
+ * `.gitignore` applies. Elsewhere it walks the directory.
30
+ *
31
+ * Holds the globs it skips: `analyze_out/`, `.git/` and the excludes it is created with.
32
+ * Created in `api/services.ts` with `new RepoFileLister(excludes)` and used by `BundleBuilder`
33
+ * for every source.
34
+ *
35
+ * @property excludes - Compiled globs of the files to skip.
24
36
  */
25
37
  export declare class RepoFileLister implements FileLister {
26
38
  private readonly excludes;
27
39
  /**
28
- * Compiles the exclude globs.
40
+ * @brief Compiles the exclude globs.
29
41
  *
30
- * @param excludes - Globs on top of {@link DEFAULT_EXCLUDES}, matched against root-relative POSIX paths.
42
+ * @param excludes - Globs matched against root-relative POSIX paths, such as the ones `ignoreGlobs` makes of an
43
+ * `.analyzeignore`. Defaults to the globs of {@link DEFAULT_IGNORE_LINES}.
31
44
  */
32
45
  constructor(excludes?: readonly string[]);
33
46
  /**
34
- * Lists the files below a directory, without the excluded ones.
47
+ * @brief Lists the files below a directory, without the excluded ones.
35
48
  *
36
49
  * @param root - Absolute directory.
37
50
  * @returns Root-relative POSIX paths, sorted.
38
51
  */
39
52
  list(root: string): Promise<string[]>;
40
- /** Tells whether a root-relative path matches an exclude glob. */
53
+ /**
54
+ * @brief Tells whether a root-relative path matches an exclude glob.
55
+ *
56
+ * @param file - Root-relative POSIX path.
57
+ * @returns `true` when a glob matches the path.
58
+ */
41
59
  private isExcluded;
42
60
  /**
43
- * Lists the tracked and untracked files git does not ignore.
61
+ * @brief Lists the tracked and untracked files git does not ignore.
44
62
  *
63
+ * @param root - Absolute directory.
45
64
  * @returns Root-relative paths, or `null` when `root` is not in a git work tree or git fails.
46
65
  */
47
66
  private listWithGit;
48
67
  /**
49
- * Walks a directory recursively, skipping excluded directories.
68
+ * @brief Walks a directory recursively, skipping excluded directories.
50
69
  *
70
+ * @param root - Absolute directory the walk starts from.
51
71
  * @param relative - Path of the directory inside `root`, `''` for `root` itself.
52
72
  * @returns Root-relative paths, unsorted.
53
73
  */
54
74
  private walk;
55
75
  }
56
76
  /**
57
- * Orders paths the way a file tree lists them: directories before files,
58
- * then by name. A README leads the files of its directory.
77
+ * @brief Orders paths the way a file tree lists them: directories before files, then by name.
78
+ *
79
+ * A README leads the files of its directory.
80
+ *
81
+ * @param a - Root-relative POSIX path.
82
+ * @param b - Root-relative POSIX path.
83
+ * @returns Negative when `a` lists first, positive when `b` does, zero for equal paths.
59
84
  */
60
85
  export declare function compareTreePaths(a: string, b: string): number;
@@ -1,21 +1,31 @@
1
- /** One term as the glossary file writes it. */
1
+ /**
2
+ * @brief One term as the glossary file writes it.
3
+ *
4
+ * @property name - Name of the term, as written.
5
+ * @property group - Text of the heading the term is listed under, or `''`.
6
+ * @property definition - Markdown of the definition, without the `_Avoid_:` lines.
7
+ * @property avoid - Words the glossary tells writers to replace with this term.
8
+ */
2
9
  export interface ParsedTerm {
3
10
  readonly name: string;
4
- /** Text of the heading the term is listed under, or `''`. */
5
11
  readonly group: string;
6
- /** Markdown. */
7
12
  readonly definition: string;
8
- /** Words the glossary tells writers to replace with this term. */
9
13
  readonly avoid: readonly string[];
10
14
  }
11
- /** A glossary file split into the text around the terms and the terms. */
15
+ /**
16
+ * @brief A glossary file split into the text around the terms and the terms.
17
+ *
18
+ * @property intro - Markdown of everything that is not a term: the title and the text around the terms.
19
+ * @property terms - The terms in file order.
20
+ */
12
21
  export interface ParsedGlossary {
13
- /** Markdown of everything that is not a term: the title and the text around the terms. */
14
22
  readonly intro: string;
15
23
  readonly terms: readonly ParsedTerm[];
16
24
  }
17
25
  /**
18
- * Reads the terms of a glossary. Two layouts are recognized:
26
+ * @brief Reads the terms of a glossary.
27
+ *
28
+ * Two layouts are recognized:
19
29
  *
20
30
  * - **Bold terms**: a line that opens with a bold name, followed by its
21
31
  * definition. Headings group the terms.
@@ -6,14 +6,13 @@ import type { ProseResolvers } from '../markdown/links';
6
6
  import type { MarkdownRenderer } from '../markdown/renderer';
7
7
  import type { TermIndex } from './terms';
8
8
  /**
9
- * Adds a glossary to the graph: one node for the file and one `term` node per
10
- * term. Used by `DocPlanner` for every `glossary.md` of the docs section. Each
11
- * term is also registered in the term index, so prose anywhere in the scan
12
- * can link to it.
9
+ * @brief Adds a glossary to the graph: one node for the file and one `term` node per term.
13
10
  *
14
- * Holds the graph, the file renderer, the markdown renderer, the shared
15
- * `TermIndex` and the prose resolvers. Created by `RepositoryScanner`, which
16
- * hands it to `DocPlanner` and `TaskPlanner`.
11
+ * Used by `DocPlanner` for every `glossary.md` of the docs section. Each term is also registered
12
+ * in the term index, so prose anywhere in the scan can link to it.
13
+ *
14
+ * Holds the graph, the file renderer, the markdown renderer, the shared `TermIndex` and the prose
15
+ * resolvers. Created by `RepositoryScanner`, which hands it to `DocPlanner` and `TaskPlanner`.
17
16
  *
18
17
  * @example
19
18
  * const terms = new TermIndex();
@@ -29,13 +28,21 @@ export declare class GlossaryPlanner {
29
28
  /**
30
29
  * Creates a planner.
31
30
  *
31
+ * @param graph - Graph the file and term nodes are added to.
32
+ * @param files - Renders the text of the glossary around the terms.
33
+ * @param markdown - Renders the definition of each term.
32
34
  * @param terms - Receives every term. Must be the index the `TermLinker` of `resolvers` reads.
35
+ * @param resolvers - Resolves the links of the glossary and its terms.
33
36
  */
34
37
  constructor(graph: GraphBuilder, files: FileRenderer, markdown: MarkdownRenderer, terms: TermIndex, resolvers: ProseResolvers);
35
38
  /**
36
- * Reads one glossary file and adds its nodes.
39
+ * @brief Reads one glossary file and adds its nodes.
37
40
  *
38
41
  * @param parent - Folder or section the file is in.
42
+ * @param root - Absolute directory `path` is relative to.
43
+ * @param path - Path of the file inside `root`.
44
+ * @param displayPath - Path the site shows.
45
+ * @param prefix - Prefix the bundle puts in front of paths from `root`.
39
46
  * @returns The node of the file.
40
47
  */
41
48
  plan(parent: NodeRef, { root, path, displayPath, prefix }: DocFile): Promise<NodeRef>;