@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
@@ -7,7 +7,7 @@ import type { DefinitionPlanner } from '../schema/definitions';
7
7
  import { type JsonObject } from '../schema/describe';
8
8
  import type { DefinitionRegistry } from '../schema/registry';
9
9
  /**
10
- * Adds an OpenAPI document to the graph: one `api` node for the document,
10
+ * @brief Adds an OpenAPI document to the graph: one `api` node for the document,
11
11
  * one `operation` node per method on a path and per webhook, one `parameter`
12
12
  * node per parameter, and one definition per entry of `components.schemas`.
13
13
  *
@@ -28,55 +28,67 @@ export declare class OpenApiPlanner {
28
28
  private readonly definitions;
29
29
  private readonly registry;
30
30
  /**
31
- * Creates a planner.
31
+ * @brief Creates a planner.
32
32
  *
33
+ * @param graph - Receives the API, operation and parameter nodes and their edges.
34
+ * @param markdown - Renders the descriptions.
33
35
  * @param resolvers - Links what descriptions refer to.
34
36
  * @param definitions - Adds the schema definitions and links type expressions.
35
37
  * @param registry - Receives the document, so refs to it from other files resolve.
36
38
  */
37
39
  constructor(graph: GraphBuilder, markdown: MarkdownRenderer, resolvers: ProseResolvers, definitions: DefinitionPlanner, registry: DefinitionRegistry);
38
40
  /**
39
- * Adds one OpenAPI document.
41
+ * @brief Adds one OpenAPI document.
40
42
  *
41
43
  * @param parent - Folder or skill the file is in.
44
+ * @param file - The file: its root, path, display path and prefix.
42
45
  * @param document - The parsed file.
43
46
  * @returns The node of the document.
44
47
  */
45
48
  plan(parent: NodeRef, file: DocFile, document: JsonObject): NodeRef;
46
49
  /**
47
- * Renders the tags a document declares, in document order, each with its description.
50
+ * @brief Renders the tags a document declares, in document order, each with its description.
48
51
  *
52
+ * @param document - The parsed document.
49
53
  * @param node - Node of the document.
54
+ * @param file - The file the document is in.
55
+ * @returns The tags, with their descriptions rendered as HTML.
50
56
  */
51
57
  private tags;
52
58
  /**
53
- * Adds one operation with its parameters.
59
+ * @brief Adds one operation with its parameters.
54
60
  *
55
61
  * @param owner - The document the operation is in.
56
62
  * @param document - The parsed document, for resolving refs.
63
+ * @param found - The operation as found in the document.
57
64
  */
58
65
  private planOperation;
59
66
  /**
60
- * Reads the request body of an operation.
67
+ * @brief Reads the request body of an operation.
61
68
  *
62
69
  * @param document - The parsed document, for resolving refs.
70
+ * @param operation - The operation object of the document.
63
71
  * @param node - Node of the operation. Schemas of the body become `type` edges from it.
72
+ * @param file - The file the document is in.
64
73
  * @returns The body, or `null` for an operation without one.
65
74
  */
66
75
  private requestBody;
67
76
  /**
68
- * Reads the responses of an operation.
77
+ * @brief Reads the responses of an operation.
69
78
  *
70
79
  * @param document - The parsed document, for resolving refs.
80
+ * @param operation - The operation object of the document.
81
+ * @param file - The file the document is in.
71
82
  * @param node - Node of the operation. A schema of a response becomes a `returns` edge from it, or a `throws` edge for an error.
72
83
  * @returns The responses in document order.
73
84
  */
74
85
  private responses;
75
86
  /**
76
- * Reads the media types of a request body or a response.
87
+ * @brief Reads the media types of a request body or a response.
77
88
  *
78
89
  * @param content - The `content` object: media type to media type object.
79
90
  * @param node - Node of the operation.
91
+ * @param file - The file the document is in.
80
92
  * @param relation - Kind of the edge a schema records from the operation.
81
93
  * @returns One entry per media type, in document order.
82
94
  */
@@ -0,0 +1,28 @@
1
+ import type { PackageRole } from '../model';
2
+ import type { Source } from './files';
3
+ /**
4
+ * @brief A directory with a package manifest, as `detectPackages` reads it.
5
+ *
6
+ * @property packageName - Name the manifest gives, such as `@g3nomaly/core`, or the directory name when it gives none.
7
+ * @property role - `app`, `library` or `workspace`. A manifest that declares an executable makes an app; otherwise a directory named `apps`/`app` above it makes an app, one named `libs`/`lib` a library, and else the manifest decides.
8
+ * @property manifest - Display path of the manifest that marks the package, such as `packages/core/package.json`.
9
+ * @property version - Version the manifest gives, or `null`.
10
+ * @property description - Description the manifest gives, or `''`.
11
+ */
12
+ export interface PackageInfo {
13
+ readonly packageName: string;
14
+ readonly role: PackageRole;
15
+ readonly manifest: string;
16
+ readonly version: string | null;
17
+ readonly description: string;
18
+ }
19
+ /**
20
+ * @brief Finds the packages of a set of sources: every directory below a root with a manifest that one of the readers understands.
21
+ *
22
+ * A directory with several manifests is read by the first reader in `READERS` that understands one. The root
23
+ * directory of a source is left out: it is the repository itself.
24
+ *
25
+ * @param sources - Directories with their files, such as the code sources of a scan.
26
+ * @returns Packages by display path of their directory, such as `packages/core`.
27
+ */
28
+ export declare function detectPackages(sources: readonly Source[]): Promise<Map<string, PackageInfo>>;
@@ -1,6 +1,9 @@
1
- /** Receives problems that should not stop a scan. */
1
+ /**
2
+ * @brief Receives problems that should not stop a scan.
3
+ *
4
+ * @property warn - Reports one problem, as one line of plain text.
5
+ */
2
6
  export interface Reporter {
3
- /** Reports one problem, as one line of plain text. */
4
7
  warn(message: string): void;
5
8
  }
6
9
  /** A reporter that drops every warning. */
@@ -4,26 +4,35 @@ import type { CodeHighlighter } from './highlight';
4
4
  import { type Reporter } from './reporter';
5
5
  import { type TaskTreeSource } from './tasks/planner';
6
6
  /**
7
- * The directories one scan reads. Skills and docs each have their own. The
7
+ * @brief The directories one scan reads. Skills and docs each have their own. The
8
8
  * code section and the database section are both read from `code`: source
9
9
  * files go to the one, SQL files to the other.
10
+ *
11
+ * @property skills - Directories of the skills section.
12
+ * @property docs - Directories of the docs section.
13
+ * @property code - Directories of the code and database sections.
14
+ * @property tasks - The task-manager trees. Their files are shown in the tasks section, and nowhere else.
10
15
  */
11
16
  export interface ScanInput {
12
17
  readonly skills: readonly Source[];
13
18
  readonly docs: readonly Source[];
14
19
  readonly code: readonly Source[];
15
- /** The task-manager trees. Their files are shown in the tasks section, and nowhere else. */
16
20
  readonly tasks: readonly TaskTreeSource[];
17
21
  }
18
- /** What a {@link RepositoryScanner} is built with. */
22
+ /**
23
+ * @brief What a {@link RepositoryScanner} is built with.
24
+ *
25
+ * @property grammarDir - Directory that relative grammar paths resolve against.
26
+ * @property highlighter - Highlights the code blocks of the markdown.
27
+ * @property reporter - Receives problems that do not stop a scan. Defaults to `silentReporter`.
28
+ */
19
29
  export interface ScannerOptions {
20
- /** Directory that relative grammar paths resolve against. */
21
30
  readonly grammarDir: string;
22
31
  readonly highlighter: CodeHighlighter;
23
32
  readonly reporter?: Reporter;
24
33
  }
25
34
  /**
26
- * Turns directories into the graph of a documentation site. Holds the parts
35
+ * @brief Turns directories into the graph of a documentation site. Holds the parts
27
36
  * that outlive one scan: the language registry, the symbol extractor, the
28
37
  * grammar loader and the markdown and file renderers. Each scan builds a fresh
29
38
  * graph and wires up every planner for it. Created in `api/services.ts` and
@@ -40,12 +49,17 @@ export declare class RepositoryScanner {
40
49
  private readonly grammars;
41
50
  private readonly markdown;
42
51
  private readonly files;
43
- /** Creates the grammar loader and the renderers the scans share. */
52
+ /**
53
+ * @brief Creates the grammar loader and the renderers the scans share.
54
+ *
55
+ * @param options - Grammar directory, highlighter and optional reporter.
56
+ */
44
57
  constructor(options: ScannerOptions);
45
58
  /**
46
- * Scans the directories of every section into one graph: skills, docs,
59
+ * @brief Scans the directories of every section into one graph: skills, docs,
47
60
  * code, database and tasks, in that order.
48
61
  *
62
+ * @param input - The directories of each section.
49
63
  * @returns The nodes and edges of the bundle, without its meta and semantic index.
50
64
  */
51
65
  scan(input: ScanInput): Promise<Pick<DocsBundle, 'nodes' | 'edges'>>;
@@ -5,16 +5,20 @@ import type { ProseResolvers } from '../markdown/links';
5
5
  import type { MarkdownRenderer } from '../markdown/renderer';
6
6
  import { type TypeExpression } from './describe';
7
7
  import type { DefinitionRegistry } from './registry';
8
- /** The file a definition is in. */
8
+ /**
9
+ * @brief The file a definition is in.
10
+ *
11
+ * @property ref - Node of the file. Definitions become its children.
12
+ * @property file - The file the definitions are in.
13
+ * @property anchors - Anchors already used on the page of the file.
14
+ */
9
15
  export interface DefinitionOwner {
10
- /** Node of the file. Definitions become its children. */
11
16
  readonly ref: NodeRef;
12
17
  readonly file: DocFile;
13
- /** Anchors already used on the page of the file. */
14
18
  readonly anchors: Set<string>;
15
19
  }
16
20
  /**
17
- * Adds named JSON Schemas to the graph: one `definition` node per schema and
21
+ * @brief Adds named JSON Schemas to the graph: one `definition` node per schema and
18
22
  * one `field` node per property. A `$ref` in a type becomes a link to the
19
23
  * definition it names, and an edge: `type` from a property, `extends` from a
20
24
  * definition.
@@ -35,23 +39,28 @@ export declare class DefinitionPlanner {
35
39
  private readonly resolvers;
36
40
  private readonly registry;
37
41
  /**
38
- * Creates a planner.
42
+ * @brief Creates a planner.
39
43
  *
44
+ * @param graph - Receives the definition and field nodes and their edges.
45
+ * @param markdown - Renders the descriptions.
40
46
  * @param resolvers - Links what descriptions refer to.
41
47
  * @param registry - Receives every definition, and finds the targets of refs.
42
48
  */
43
49
  constructor(graph: GraphBuilder, markdown: MarkdownRenderer, resolvers: ProseResolvers, registry: DefinitionRegistry);
44
50
  /**
45
- * Adds one definition with its properties.
51
+ * @brief Adds one definition with its properties.
46
52
  *
53
+ * @param owner - The file the definition is in.
47
54
  * @param name - Name of the definition, as the page shows it.
48
55
  * @param pointer - JSON pointer of the schema inside its file. Refs to that place link to the definition.
56
+ * @param schema - The schema: an object, or `true` or `false`.
49
57
  * @returns The node of the definition.
50
58
  */
51
59
  add(owner: DefinitionOwner, name: string, pointer: string, schema: unknown): NodeRef;
52
60
  /**
53
- * Turns a type expression into text with links to the definitions its refs name.
61
+ * @brief Turns a type expression into text with links to the definitions its refs name.
54
62
  *
63
+ * @param expression - The type expression, with the spans of its refs.
55
64
  * @param from - Node the expression belongs to.
56
65
  * @param file - The file the expression is in. A relative ref starts there.
57
66
  * @param relation - Kind of the edge each resolved ref records from `from`.
@@ -59,10 +68,11 @@ export declare class DefinitionPlanner {
59
68
  */
60
69
  linked(expression: TypeExpression, from: NodeRef, file: DocFile, relation: EdgeKind): LinkedText;
61
70
  /**
62
- * Renders a description.
71
+ * @brief Renders a description as HTML.
63
72
  *
64
73
  * @param markdown - Markdown of the description, or `''`.
65
74
  * @param node - Node the description belongs to. Links in it become edges from this node.
75
+ * @param file - The file the description is in. Its root, path and prefix resolve links.
66
76
  * @returns HTML, or `''`.
67
77
  */
68
78
  html(markdown: string, node: NodeRef, { root, path, prefix }: DocFile): Promise<string>;
@@ -1,62 +1,86 @@
1
1
  /** A JSON object as parsed from JSON or YAML. */
2
2
  export type JsonObject = Readonly<Record<string, unknown>>;
3
3
  /**
4
- * Tells a JSON object from every other value: true for an object that is no
4
+ * @brief Tells a JSON object from every other value: true for an object that is no
5
5
  * array and not `null`.
6
+ *
7
+ * @param value - Any value, as parsed from JSON or YAML.
6
8
  */
7
9
  export declare function isJsonObject(value: unknown): value is JsonObject;
8
- /** A span of a type expression that stands for a `$ref`. */
10
+ /**
11
+ * @brief A span of a type expression that stands for a `$ref`.
12
+ *
13
+ * @property start - Offset in the type text where the span starts.
14
+ * @property end - Offset in the type text where the span ends.
15
+ * @property ref - The `$ref` as the schema writes it.
16
+ */
9
17
  export interface SchemaRef {
10
18
  readonly start: number;
11
19
  readonly end: number;
12
- /** The `$ref` as the schema writes it. */
13
20
  readonly ref: string;
14
21
  }
15
- /** What a schema allows, as text: `string[]`, `Cat | Dog`, `"open" | "closed"`. */
22
+ /**
23
+ * @brief What a schema allows, as text: `string[]`, `Cat | Dog`, `"open" | "closed"`.
24
+ *
25
+ * @property text - The type as text.
26
+ * @property refs - The spans of the text that are `$ref`s, in text order, not overlapping.
27
+ */
16
28
  export interface TypeExpression {
17
29
  readonly text: string;
18
- /** In text order, not overlapping. */
19
30
  readonly refs: readonly SchemaRef[];
20
31
  }
21
- /** One property of an object schema. A nested property has a dotted name. */
32
+ /**
33
+ * @brief One property of an object schema. A nested property has a dotted name.
34
+ *
35
+ * @property name - Name of the property, dotted for a nested one: `city`, `address.city`, `items[].sku`.
36
+ * @property type - The type of the property.
37
+ * @property required - True when the parent schema requires the property.
38
+ * @property defaultValue - The default as JSON, or `null`.
39
+ * @property description - Markdown.
40
+ * @property constraints - Keywords that narrow the type, as `keyword: value`.
41
+ */
22
42
  export interface SchemaProperty {
23
- /** `city`, `address.city`, `items[].sku`. */
24
43
  readonly name: string;
25
44
  readonly type: TypeExpression;
26
45
  readonly required: boolean;
27
- /** The default as JSON, or `null`. */
28
46
  readonly defaultValue: string | null;
29
- /** Markdown. */
30
47
  readonly description: string;
31
- /** Keywords that narrow the type, as `keyword: value`. */
32
48
  readonly constraints: readonly string[];
33
49
  }
34
- /** What a schema says, in the shape the site shows. */
50
+ /**
51
+ * @brief What a schema says, in the shape the site shows.
52
+ *
53
+ * @property type - The type of the schema.
54
+ * @property description - Markdown.
55
+ * @property constraints - Keywords that narrow the type, as `keyword: value`.
56
+ * @property values - Values of an `enum` or a `const`, as JSON. Empty when they fit inside `type`.
57
+ * @property deprecated - True when the schema is deprecated.
58
+ * @property properties - Every property, nested ones included, in schema order.
59
+ */
35
60
  export interface SchemaDescription {
36
61
  readonly type: TypeExpression;
37
- /** Markdown. */
38
62
  readonly description: string;
39
63
  readonly constraints: readonly string[];
40
- /** Values of an `enum` or a `const`, as JSON. */
41
64
  readonly values: readonly string[];
42
65
  readonly deprecated: boolean;
43
66
  readonly properties: readonly SchemaProperty[];
44
67
  }
45
68
  /**
46
- * Reads the last part of a `$ref` as a name.
69
+ * @brief Reads the last part of a `$ref` as a name.
47
70
  *
48
71
  * @param ref - A `$ref`, such as `#/$defs/Booking` or `cargo.schema.json`.
49
72
  * @returns `Booking` for a ref into a file, the file name for a ref to a whole file.
50
73
  */
51
74
  export declare function refName(ref: string): string;
52
75
  /**
53
- * Decodes one segment of a JSON pointer.
76
+ * @brief Decodes one segment of a JSON pointer.
54
77
  *
78
+ * @param segment - One segment between two `/`, possibly percent-encoded.
55
79
  * @returns The key it names: percent escapes decoded, `~1` as `/` and `~0` as `~`.
56
80
  */
57
81
  export declare function decodePointerSegment(segment: string): string;
58
82
  /**
59
- * Writes what a schema allows as a type expression.
83
+ * @brief Writes what a schema allows as a type expression.
60
84
  *
61
85
  * @param schema - A schema: an object, or `true` or `false`.
62
86
  * @param depth - Nesting of the schema inside the one that is described.
@@ -64,7 +88,7 @@ export declare function decodePointerSegment(segment: string): string;
64
88
  */
65
89
  export declare function typeOf(schema: unknown, depth?: number): TypeExpression;
66
90
  /**
67
- * Describes a JSON Schema in the shape the site shows: a type expression, a
91
+ * @brief Describes a JSON Schema in the shape the site shows: a type expression, a
68
92
  * description, constraints and a flat list of properties.
69
93
  *
70
94
  * @param schema - The schema: an object, or `true` or `false`.
@@ -72,8 +96,10 @@ export declare function typeOf(schema: unknown, depth?: number): TypeExpression;
72
96
  */
73
97
  export declare function describeSchema(schema: unknown): SchemaDescription;
74
98
  /**
75
- * Tells whether a schema says anything about a value: true when it has a
99
+ * @brief Tells whether a schema says anything about a value: true when it has a
76
100
  * type, properties, a composition, values or a `$ref`. A file that only
77
101
  * holds `$defs` has a root schema that does not.
102
+ *
103
+ * @param schema - The schema to check.
78
104
  */
79
105
  export declare function describesValue(schema: JsonObject): boolean;
@@ -7,7 +7,7 @@ import type { DefinitionPlanner } from './definitions';
7
7
  import { type JsonObject } from './describe';
8
8
  import type { DefinitionRegistry } from './registry';
9
9
  /**
10
- * Adds a JSON Schema file to the graph: one `schema` node for the file, with
10
+ * @brief Adds a JSON Schema file to the graph: one `schema` node for the file, with
11
11
  * its text, and one definition per schema it names. The root schema is a
12
12
  * definition when it describes a value.
13
13
  *
@@ -28,17 +28,20 @@ export declare class JsonSchemaPlanner {
28
28
  private readonly definitions;
29
29
  private readonly registry;
30
30
  /**
31
- * Creates a planner.
31
+ * @brief Creates a planner.
32
32
  *
33
+ * @param graph - Receives the schema and definition nodes and their edges.
33
34
  * @param files - Renders the text of the file.
34
35
  * @param resolvers - Links what the file refers to.
36
+ * @param definitions - Adds the definitions the schema names.
35
37
  * @param registry - Receives the file and its `$id`, so refs to the file resolve.
36
38
  */
37
39
  constructor(graph: GraphBuilder, files: FileRenderer, resolvers: ProseResolvers, definitions: DefinitionPlanner, registry: DefinitionRegistry);
38
40
  /**
39
- * Adds one schema file.
41
+ * @brief Adds one schema file.
40
42
  *
41
43
  * @param parent - Folder or skill the file is in.
44
+ * @param file - The file: its root, path, display path and prefix.
42
45
  * @param schema - The parsed file.
43
46
  * @returns The node of the file.
44
47
  */
@@ -1,49 +1,56 @@
1
1
  import type { NodeRef } from '../../model';
2
2
  /**
3
- * Writes a JSON pointer in one spelling, so two spellings of one place compare equal.
3
+ * @brief Writes a JSON pointer in one spelling, so two spellings of one place compare equal.
4
4
  *
5
5
  * @param pointer - A pointer, with or without the `#` in front.
6
6
  * @returns The pointer with every segment decoded. `''` names the root.
7
7
  */
8
8
  export declare function normalizePointer(pointer: string): string;
9
- /** What a `$ref` points at. */
9
+ /**
10
+ * @brief What a `$ref` points at.
11
+ *
12
+ * @property ref - The node that shows the place.
13
+ * @property name - Name of the node, as a type expression shows it.
14
+ */
10
15
  export interface RefTarget {
11
16
  readonly ref: NodeRef;
12
- /** Name of the node, as a type expression shows it. */
13
17
  readonly name: string;
14
18
  }
15
19
  /**
16
- * Finds the nodes that `$ref`s point at, across the JSON Schema files and
20
+ * @brief Finds the nodes that `$ref`s point at, across the JSON Schema files and
17
21
  * OpenAPI documents of one scan.
18
22
  *
19
- * Holds a map from `path#pointer` to the node at that place, and a map from
20
- * `$id` to file path. Created once per scan by `RepositoryScanner` and shared
21
- * by `JsonSchemaPlanner`, `OpenApiPlanner` and `DefinitionPlanner`. The
22
- * planners register every file and definition when they add it;
23
- * `DefinitionPlanner` resolves refs when the content of the graph is built.
24
- * By then every file is read, so a ref can point into a later file.
23
+ * Created once per scan by `RepositoryScanner` and shared by `JsonSchemaPlanner`,
24
+ * `OpenApiPlanner` and `DefinitionPlanner`. The planners register every file and
25
+ * definition when they add it; `DefinitionPlanner` resolves refs when the content
26
+ * of the graph is built. By then every file is read, so a ref can point into a
27
+ * later file.
28
+ *
29
+ * @property places - The node at each `path#pointer` place.
30
+ * @property ids - Path of each schema file by its `$id`.
31
+ * @example
32
+ * const registry = new DefinitionRegistry();
25
33
  */
26
34
  export declare class DefinitionRegistry {
27
- /** `path#pointer` to the node at that place. */
28
35
  private readonly places;
29
- /** `$id` of a schema file to its path. */
30
36
  private readonly ids;
31
37
  /**
32
- * Records the node that shows a place in a file.
38
+ * @brief Records the node that shows a place in a file.
33
39
  *
34
40
  * @param path - Path of the file, as the site shows it.
35
41
  * @param pointer - JSON pointer of the place inside the file. `''` is the whole file.
42
+ * @param target - The node that shows the place, and its name.
36
43
  */
37
44
  register(path: string, pointer: string, target: RefTarget): void;
38
45
  /**
39
- * Records the `$id` of a schema file, so a ref by that id finds the file.
46
+ * @brief Records the `$id` of a schema file, so a ref by that id finds the file.
40
47
  *
41
48
  * @param id - The `$id`, an absolute URI.
42
49
  * @param path - Path of the file, as the site shows it.
43
50
  */
44
51
  registerId(id: string, path: string): void;
45
52
  /**
46
- * Finds the node a `$ref` points at.
53
+ * @brief Finds the node a `$ref` points at.
47
54
  *
48
55
  * @param ref - The `$ref` as written: `#/$defs/Cargo`, `cargo.schema.json#/$defs/Cargo`, or the `$id` of a file.
49
56
  * @param fromPath - Path of the file the ref is in. A relative ref starts there.
@@ -51,7 +58,7 @@ export declare class DefinitionRegistry {
51
58
  */
52
59
  resolve(ref: string, fromPath: string): RefTarget | null;
53
60
  /**
54
- * Finds the file a URI names.
61
+ * @brief Finds the file a URI names.
55
62
  *
56
63
  * @param uri - The part of a ref in front of the `#`.
57
64
  * @param fromPath - Path of the file the ref is in, as the site shows it.
@@ -2,7 +2,7 @@ import type { FileKind } from '../../model';
2
2
  /** What a file inside a skill directory can be. `source` is code, shown with its symbols. */
3
3
  export type SkillFileKind = Exclude<FileKind, 'skill' | 'document'> | 'source';
4
4
  /**
5
- * Kind of a file in a skill, from where it is and what it is. The first rule that matches wins.
5
+ * @brief Classifies a file in a skill by where it is and what it is. The first rule that matches wins.
6
6
  *
7
7
  * | Rule | Kind |
8
8
  * |---|---|
@@ -16,5 +16,6 @@ export type SkillFileKind = Exclude<FileKind, 'skill' | 'document'> | 'source';
16
16
  *
17
17
  * @param path - Path relative to the skill directory.
18
18
  * @param isSource - Answers whether a file is source code.
19
+ * @returns The kind of the file, from the first rule that matches it.
19
20
  */
20
21
  export declare function classifySkillFile(path: string, isSource: (path: string) => boolean): SkillFileKind;
@@ -1,12 +1,15 @@
1
1
  /** File name that makes a directory a skill. */
2
2
  export declare const SKILL_FILE = "SKILL.md";
3
- /** A skill directory and the files that belong to it. */
3
+ /**
4
+ * A skill directory and the files that belong to it.
5
+ *
6
+ * @property directory - Root-relative directory of the `SKILL.md`. `''` for the root itself.
7
+ * @property skillFile - Root-relative path of the `SKILL.md`.
8
+ * @property files - Every other file of the skill, root-relative.
9
+ */
4
10
  export interface SkillLayout {
5
- /** Root-relative directory of the `SKILL.md`. `''` for the root itself. */
6
11
  readonly directory: string;
7
- /** Root-relative path of the `SKILL.md`. */
8
12
  readonly skillFile: string;
9
- /** Every other file of the skill, root-relative. */
10
13
  readonly files: string[];
11
14
  }
12
15
  /**
@@ -16,13 +19,28 @@ export interface SkillLayout {
16
19
  * @param directory - Root-relative POSIX directory. `''` is the root and holds every file.
17
20
  */
18
21
  export declare function isInside(file: string, directory: string): boolean;
22
+ /** Directories of AI tools that hold installed skills. A `SKILL.md` elsewhere in a repository is a doc. */
23
+ export declare const AI_DIRECTORIES: readonly string[];
19
24
  /**
20
- * Finds the skills in a file list. A skill is a directory with a `SKILL.md`.
21
- * Each file belongs to the deepest skill directory around it.
25
+ * @brief Tells whether a file is inside the directory of an AI tool, such as `.claude/skills/deploy/SKILL.md`.
26
+ *
27
+ * @param file - Root-relative POSIX path.
28
+ */
29
+ export declare function isInAiDirectory(file: string): boolean;
30
+ /**
31
+ * @brief Finds the skills in a file list. A skill is a directory with a `SKILL.md` inside the directory of
32
+ * an AI tool, see `AI_DIRECTORIES`. Each file belongs to the deepest skill directory around it.
22
33
  *
23
34
  * @param files - Root-relative POSIX paths.
35
+ * @param anywhere - Counts a `SKILL.md` outside an AI directory too, for a directory the reader names as skills.
24
36
  * @returns One layout per `SKILL.md`, deepest directory first.
25
37
  */
26
- export declare function skillLayouts(files: readonly string[]): SkillLayout[];
27
- /** The files of a list that belong to a skill, `SKILL.md` files included. */
28
- export declare function skillOwnedFiles(files: readonly string[]): Set<string>;
38
+ export declare function skillLayouts(files: readonly string[], anywhere?: boolean): SkillLayout[];
39
+ /**
40
+ * @brief Finds the files of a list that belong to a skill, `SKILL.md` files included.
41
+ *
42
+ * @param files - Root-relative POSIX paths.
43
+ * @param anywhere - Counts a `SKILL.md` outside an AI directory too, as `skillLayouts` does.
44
+ * @returns The `SKILL.md` files and the other files of every skill in the list.
45
+ */
46
+ export declare function skillOwnedFiles(files: readonly string[], anywhere?: boolean): Set<string>;
@@ -6,7 +6,7 @@ import type { GraphBuilder } from '../graph/builder';
6
6
  import type { ProseResolvers } from '../markdown/links';
7
7
  import type { SpecPlanner } from '../specs';
8
8
  /**
9
- * Adds skills to the graph. A skill is its `SKILL.md`. The other files of its
9
+ * @brief Adds skills to the graph. A skill is its `SKILL.md`. The other files of its
10
10
  * directory become its descendants, each with the kind its place and type
11
11
  * give it. A file that is an OpenAPI document or a JSON Schema goes to the
12
12
  * `SpecPlanner`, a source file to the `CodePlanner`.
@@ -23,23 +23,38 @@ export declare class SkillPlanner {
23
23
  private readonly code;
24
24
  private readonly resolvers;
25
25
  private readonly specs;
26
- /** Creates a planner. */
26
+ /**
27
+ * Creates a planner.
28
+ *
29
+ * @param graph - Receives the skill, folder and file nodes.
30
+ * @param files - Renders the `SKILL.md` and the other files.
31
+ * @param code - Plans the source files of skills.
32
+ * @param resolvers - Links what the skill files refer to.
33
+ * @param specs - Plans the JSON and YAML files that are specs.
34
+ */
27
35
  constructor(graph: GraphBuilder, files: FileRenderer, code: CodePlanner, resolvers: ProseResolvers, specs: SpecPlanner);
28
36
  /**
29
37
  * Adds the skills of every source, sorted by name, each with a unique slug.
30
38
  *
31
39
  * @param section - Node of the skills section, the parent of every skill.
40
+ * @param sources - Sources to read the skills from, each with the files it holds.
32
41
  */
33
42
  plan(section: NodeRef, sources: readonly Source[]): Promise<void>;
34
43
  /**
35
- * Reads the `SKILL.md` of a skill and picks its name: the `name` field of
44
+ * @brief Reads the `SKILL.md` of a skill and picks its name: the `name` field of
36
45
  * the frontmatter, else the first `#` heading, else the directory name.
46
+ *
47
+ * @param source - Source the skill is in.
48
+ * @param layout - Files of the skill.
49
+ * @returns The skill with its text and name.
37
50
  */
38
51
  private read;
39
52
  /**
40
- * Adds one skill node and a node for each of its files, under folder nodes
53
+ * @brief Adds one skill node and a node for each of its files, under folder nodes
41
54
  * that mirror the skill directory.
42
55
  *
56
+ * @param section - Node of the skills section, the parent of the skill.
57
+ * @param skill - The skill as read from disk.
43
58
  * @param slugs - Slugs already taken by other skills. Receives the slug of this one.
44
59
  */
45
60
  private planSkill;