@g3nomaly/analyze 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +76 -2
  3. package/dist/THIRD_PARTY_LICENSES.txt +1904 -0
  4. package/dist/api/bundle-builder.d.ts +94 -0
  5. package/dist/api/bundle-cache.d.ts +73 -0
  6. package/dist/api/bundle-loader.d.ts +65 -0
  7. package/dist/api/create-docs.d.ts +91 -0
  8. package/dist/api/embedding.d.ts +41 -0
  9. package/dist/api/errors.d.ts +35 -0
  10. package/dist/api/list.d.ts +106 -0
  11. package/dist/api/options.d.ts +74 -0
  12. package/dist/api/refs.d.ts +136 -0
  13. package/dist/api/scan.d.ts +56 -0
  14. package/dist/api/search.d.ts +132 -0
  15. package/dist/api/services.d.ts +15 -0
  16. package/dist/api/show.d.ts +100 -0
  17. package/dist/api/site-reader.d.ts +19 -0
  18. package/dist/api/site-writer.d.ts +43 -0
  19. package/dist/api/source.d.ts +57 -0
  20. package/dist/api/target.d.ts +12 -0
  21. package/dist/api/template.d.ts +5 -0
  22. package/dist/assets/tree-sitter-c-sharp.wasm +0 -0
  23. package/dist/assets/tree-sitter-c.wasm +0 -0
  24. package/dist/assets/tree-sitter-cpp.wasm +0 -0
  25. package/dist/assets/tree-sitter-go.wasm +0 -0
  26. package/dist/assets/tree-sitter-java.wasm +0 -0
  27. package/dist/assets/tree-sitter-javascript.wasm +0 -0
  28. package/dist/assets/tree-sitter-kotlin.wasm +0 -0
  29. package/dist/assets/tree-sitter-php.wasm +0 -0
  30. package/dist/assets/tree-sitter-python.wasm +0 -0
  31. package/dist/assets/tree-sitter-ruby.wasm +0 -0
  32. package/dist/assets/tree-sitter-rust.wasm +0 -0
  33. package/dist/assets/tree-sitter-scala.wasm +0 -0
  34. package/dist/assets/tree-sitter-tsx.wasm +0 -0
  35. package/dist/assets/tree-sitter-typescript.wasm +0 -0
  36. package/dist/assets/vectors.bin +0 -0
  37. package/dist/assets/vocab.txt +33731 -0
  38. package/dist/cli.js +9317 -0
  39. package/dist/embeddings/abbreviations.d.ts +7 -0
  40. package/dist/embeddings/index-builder.d.ts +12 -0
  41. package/dist/embeddings/index.d.ts +10 -0
  42. package/dist/embeddings/model.d.ts +126 -0
  43. package/dist/embeddings/searcher.d.ts +84 -0
  44. package/dist/embeddings/vectors.d.ts +77 -0
  45. package/dist/embeddings/words.d.ts +46 -0
  46. package/dist/index.d.ts +9 -0
  47. package/dist/index.js +8747 -0
  48. package/dist/model/index.d.ts +788 -0
  49. package/dist/model/registry.d.ts +687 -0
  50. package/dist/query/graph.d.ts +123 -0
  51. package/dist/query/index.d.ts +4 -0
  52. package/dist/query/name-search.d.ts +65 -0
  53. package/dist/query/semantic.d.ts +38 -0
  54. package/dist/query/text.d.ts +22 -0
  55. package/dist/retrieval/describe.d.ts +33 -0
  56. package/dist/retrieval/filter.d.ts +36 -0
  57. package/dist/retrieval/index.d.ts +7 -0
  58. package/dist/retrieval/markdown.d.ts +17 -0
  59. package/dist/retrieval/report.d.ts +291 -0
  60. package/dist/retrieval/resolve.d.ts +31 -0
  61. package/dist/retrieval/retriever.d.ts +105 -0
  62. package/dist/retrieval/summary.d.ts +27 -0
  63. package/dist/scanner/code/doc/clean.d.ts +36 -0
  64. package/dist/scanner/code/doc/index.d.ts +12 -0
  65. package/dist/scanner/code/doc/markdown.d.ts +8 -0
  66. package/dist/scanner/code/doc/python.d.ts +8 -0
  67. package/dist/scanner/code/doc/tagged.d.ts +19 -0
  68. package/dist/scanner/code/doc/types.d.ts +33 -0
  69. package/dist/scanner/code/doc/xml.d.ts +8 -0
  70. package/dist/scanner/code/example.d.ts +57 -0
  71. package/dist/scanner/code/extract.d.ts +113 -0
  72. package/dist/scanner/code/grammar.d.ts +44 -0
  73. package/dist/scanner/code/language.d.ts +183 -0
  74. package/dist/scanner/code/languages/c-family.d.ts +5 -0
  75. package/dist/scanner/code/languages/csharp.d.ts +3 -0
  76. package/dist/scanner/code/languages/ecmascript.d.ts +7 -0
  77. package/dist/scanner/code/languages/go.d.ts +3 -0
  78. package/dist/scanner/code/languages/index.d.ts +33 -0
  79. package/dist/scanner/code/languages/java.d.ts +3 -0
  80. package/dist/scanner/code/languages/kotlin.d.ts +3 -0
  81. package/dist/scanner/code/languages/php.d.ts +3 -0
  82. package/dist/scanner/code/languages/python.d.ts +3 -0
  83. package/dist/scanner/code/languages/ruby.d.ts +3 -0
  84. package/dist/scanner/code/languages/rust.d.ts +3 -0
  85. package/dist/scanner/code/languages/scala.d.ts +3 -0
  86. package/dist/scanner/code/languages/shared.d.ts +36 -0
  87. package/dist/scanner/code/planner.d.ts +107 -0
  88. package/dist/scanner/code/symbols.d.ts +134 -0
  89. package/dist/scanner/code/types.d.ts +126 -0
  90. package/dist/scanner/config.d.ts +42 -0
  91. package/dist/scanner/content.d.ts +73 -0
  92. package/dist/scanner/decisions/parse.d.ts +37 -0
  93. package/dist/scanner/decisions/planner.d.ts +42 -0
  94. package/dist/scanner/docs.d.ts +69 -0
  95. package/dist/scanner/files.d.ts +85 -0
  96. package/dist/scanner/glossary/parse.d.ts +40 -0
  97. package/dist/scanner/glossary/planner.d.ts +49 -0
  98. package/dist/scanner/glossary/terms.d.ts +116 -0
  99. package/dist/scanner/graph/builder.d.ts +114 -0
  100. package/dist/scanner/highlight.d.ts +54 -0
  101. package/dist/scanner/ignore.d.ts +25 -0
  102. package/dist/scanner/index.d.ts +43 -0
  103. package/dist/scanner/markdown/frontmatter.d.ts +24 -0
  104. package/dist/scanner/markdown/links.d.ts +60 -0
  105. package/dist/scanner/markdown/outline.d.ts +35 -0
  106. package/dist/scanner/markdown/renderer.d.ts +63 -0
  107. package/dist/scanner/openapi/planner.d.ts +96 -0
  108. package/dist/scanner/packages.d.ts +28 -0
  109. package/dist/scanner/reporter.d.ts +10 -0
  110. package/dist/scanner/scanner.d.ts +66 -0
  111. package/dist/scanner/schema/definitions.d.ts +79 -0
  112. package/dist/scanner/schema/describe.d.ts +105 -0
  113. package/dist/scanner/schema/planner.d.ts +49 -0
  114. package/dist/scanner/schema/registry.d.ts +68 -0
  115. package/dist/scanner/skills/classify.d.ts +21 -0
  116. package/dist/scanner/skills/layout.d.ts +46 -0
  117. package/dist/scanner/skills/planner.d.ts +61 -0
  118. package/dist/scanner/specs.d.ts +56 -0
  119. package/dist/scanner/sql/catalog.d.ts +98 -0
  120. package/dist/scanner/sql/cursor.d.ts +112 -0
  121. package/dist/scanner/sql/database.d.ts +51 -0
  122. package/dist/scanner/sql/parse.d.ts +122 -0
  123. package/dist/scanner/sql/planner.d.ts +69 -0
  124. package/dist/scanner/sql/query.d.ts +73 -0
  125. package/dist/scanner/sql/registry.d.ts +63 -0
  126. package/dist/scanner/sql/source.d.ts +10 -0
  127. package/dist/scanner/sql/statements.d.ts +42 -0
  128. package/dist/scanner/sql/tokens.d.ts +51 -0
  129. package/dist/scanner/tasks/layout.d.ts +52 -0
  130. package/dist/scanner/tasks/planner.d.ts +130 -0
  131. package/dist/scanner/tasks/schema.d.ts +88 -0
  132. package/dist/scanner/text.d.ts +14 -0
  133. package/package.json +104 -4
@@ -0,0 +1,73 @@
1
+ import type { QueryEffect, QueryTable } from '../../model';
2
+ /**
3
+ * A column a statement names.
4
+ *
5
+ * @property table - Name of the table in front of the column, with an alias replaced by its table. `null` for a column without one.
6
+ * @property column - Name of the column. `*` for every column.
7
+ */
8
+ export interface ParsedColumnRef {
9
+ readonly table: string | null;
10
+ readonly column: string;
11
+ }
12
+ /**
13
+ * One placeholder of a statement.
14
+ *
15
+ * @property name - The placeholder as written: `:map_id`, `@id`, `$id`, `?2`. A plain `?` gets the number SQLite gives it: `?1`.
16
+ * @property column - The column the placeholder is compared with or stored in, when the statement shows one.
17
+ * @property count - True for the row count of a `LIMIT` or an `OFFSET`.
18
+ */
19
+ export interface ParsedParameter {
20
+ readonly name: string;
21
+ readonly column: ParsedColumnRef | null;
22
+ readonly count: boolean;
23
+ }
24
+ /**
25
+ * One column of the rows a statement returns.
26
+ *
27
+ * @property name - Name of the column in the result: its alias, else the column it selects, else the expression as written. `*` and `t.*` stand for every column of a table.
28
+ * @property expression - The expression behind an alias, as written. `''` for a column of a table.
29
+ * @property column - The column of a table it selects. `null` for an expression.
30
+ */
31
+ export interface ParsedResultColumn {
32
+ readonly name: string;
33
+ readonly expression: string;
34
+ readonly column: ParsedColumnRef | null;
35
+ }
36
+ /** A table a statement names, and what it does with it. */
37
+ export type ParsedQueryTable = Pick<QueryTable, 'name' | 'access'>;
38
+ /**
39
+ * One entry of a query catalog, as its file writes it.
40
+ *
41
+ * @property name - Name from a `-- name:` line above the SQL. `null` when the file has no such line, so the file names the entry.
42
+ * @property line - 1-based line the SQL starts on.
43
+ * @property effect - Whether the statement reads, writes or only controls.
44
+ * @property verb - The keywords that open the statement, in capitals: `SELECT`, `INSERT`, `BEGIN IMMEDIATE`.
45
+ * @property note - Markdown from the comments above the SQL.
46
+ * @property sql - The SQL as written, without the closing semicolon.
47
+ * @property parameters - Placeholders in the order SQLite numbers them, each once.
48
+ * @property tables - Tables the statement names, in the order they first appear, each once per access.
49
+ * @property columns - Result columns in result order. Empty for a statement that returns no rows.
50
+ */
51
+ export interface ParsedQuery {
52
+ readonly name: string | null;
53
+ readonly line: number;
54
+ readonly effect: QueryEffect;
55
+ readonly verb: string;
56
+ readonly note: string;
57
+ readonly sql: string;
58
+ readonly parameters: readonly ParsedParameter[];
59
+ readonly tables: readonly ParsedQueryTable[];
60
+ readonly columns: readonly ParsedResultColumn[];
61
+ }
62
+ /**
63
+ * @brief Reads a SQL file of a query catalog: a file of queries and statements that
64
+ * creates no table. The SQL is read as text and never run.
65
+ *
66
+ * A file is one entry, named by the file. A file that names its statements
67
+ * with comment lines such as `-- name: list_bookings` is one entry per name.
68
+ * The comments above the SQL of an entry are its note.
69
+ *
70
+ * @param source - Text of the file.
71
+ * @returns The entries in file order. Empty for a file without a statement.
72
+ */
73
+ export declare function parseQueryFile(source: string): ParsedQuery[];
@@ -0,0 +1,63 @@
1
+ import type { NodeRef } from '../../model';
2
+ /**
3
+ * A column of a table as the registry knows it.
4
+ *
5
+ * @property ref - Node of the column.
6
+ * @property name - Name of the column, as its table writes it.
7
+ * @property type - Declared type, or `''`.
8
+ */
9
+ export interface ColumnEntry {
10
+ readonly ref: NodeRef;
11
+ readonly name: string;
12
+ readonly type: string;
13
+ }
14
+ /**
15
+ * A table as the registry knows it.
16
+ *
17
+ * @property ref - Node of the table.
18
+ * @property name - Name of the table, as its statement writes it.
19
+ * @property path - Display path (`SourceFile.displayPath`) of the file that creates the table.
20
+ * @property primaryKey - Columns of its primary key, in key order.
21
+ * @property columns - Its columns, in table order.
22
+ */
23
+ export interface TableEntry {
24
+ readonly ref: NodeRef;
25
+ readonly name: string;
26
+ readonly path: string;
27
+ readonly primaryKey: readonly string[];
28
+ readonly columns: readonly ColumnEntry[];
29
+ }
30
+ /**
31
+ * Finds a column of a table by name. Capitals do not matter, as in SQLite.
32
+ *
33
+ * @param table - The table to search.
34
+ * @param name - Name of the column, in any case.
35
+ * @returns The column, or `undefined` when the table has none of that name.
36
+ */
37
+ export declare function columnOf(table: TableEntry, name: string): ColumnEntry | undefined;
38
+ /**
39
+ * @brief Finds tables by name across the SQL files of one scan.
40
+ *
41
+ * `SqlPlanner` registers every table when it adds it, and looks tables up
42
+ * when the content of the graph is built. By then every file is read, so a
43
+ * foreign key can point at a table of a later file. `CatalogPlanner` looks
44
+ * up the tables and columns that queries name. Holds the tables by their
45
+ * lowercase name. `RepositoryScanner` creates one per scan and hands it to
46
+ * both planners.
47
+ */
48
+ export declare class TableRegistry {
49
+ private readonly byName;
50
+ /**
51
+ * Records a table under its name. Capitals of the name do not matter, as in SQLite.
52
+ *
53
+ * @param entry - The table to record.
54
+ */
55
+ register(entry: TableEntry): void;
56
+ /**
57
+ * Finds the table a name in a SQL file means.
58
+ *
59
+ * @param path - Display path of the file the name is in, as in `TableEntry.path`.
60
+ * @returns The table of that name in the same file, else the only table of that name in the scan, else `null`.
61
+ */
62
+ find(name: string, path: string): TableEntry | null;
63
+ }
@@ -0,0 +1,10 @@
1
+ import type { SourceFile } from '../code/planner';
2
+ import type { Reporter } from '../reporter';
3
+ /**
4
+ * Reads the text of a SQL file.
5
+ *
6
+ * @param file - The SQL file to read, with its root and path.
7
+ * @param reporter - Receives a warning when the file cannot be read.
8
+ * @returns The text, or `null` for a file that is too large or cannot be read.
9
+ */
10
+ export declare function readSqlFile(file: SourceFile, reporter: Reporter): Promise<string | null>;
@@ -0,0 +1,42 @@
1
+ import type { SqlComment, SqlToken } from './tokens';
2
+ /**
3
+ * Turns comments into markdown.
4
+ *
5
+ * @param comments - Comments in file order.
6
+ * @returns Their text without ruler lines and shared indentation. Comments that are apart become paragraphs.
7
+ */
8
+ export declare function markdownOf(comments: readonly SqlComment[]): string;
9
+ /**
10
+ * @brief Finds the comments that describe what starts on a line: the comments on
11
+ * lines of their own directly above it, without a blank line between.
12
+ *
13
+ * @param comments - Every comment of the file, in file order.
14
+ * @param line - 1-based line the described statement or column starts on.
15
+ * @returns The comments, in file order.
16
+ */
17
+ export declare function commentsAbove(comments: readonly SqlComment[], line: number): SqlComment[];
18
+ /**
19
+ * One statement of a file: the tokens it is made of, without its closing semicolon.
20
+ *
21
+ * @property tokens - Tokens of the statement, in text order.
22
+ */
23
+ export interface Statement {
24
+ readonly tokens: readonly SqlToken[];
25
+ }
26
+ /**
27
+ * @brief Splits the tokens of a file into statements at the semicolons. The
28
+ * semicolons inside the body of a trigger do not end its statement.
29
+ *
30
+ * @param tokens - Every token of the file.
31
+ * @returns The statements, each without its closing semicolon.
32
+ */
33
+ export declare function statementsOf(tokens: readonly SqlToken[]): Statement[];
34
+ /**
35
+ * Reads a statement back as written.
36
+ *
37
+ * @param source - Text of the whole file.
38
+ * @param first - Token the statement starts with.
39
+ * @param last - Token the statement ends with.
40
+ * @returns The statement with its line breaks, without the closing semicolon.
41
+ */
42
+ export declare function sqlOf(source: string, first: SqlToken, last: SqlToken): string;
@@ -0,0 +1,51 @@
1
+ /** What a token of a SQL text is. A `name` is a quoted identifier. */
2
+ export type SqlTokenKind = 'word' | 'name' | 'string' | 'number' | 'symbol';
3
+ /**
4
+ * One token of a SQL text. Comments are no tokens.
5
+ *
6
+ * @property kind - What the token is.
7
+ * @property value - The token without quotes and escapes. For a word, a number or a symbol: the token as written.
8
+ * @property line - 1-based line the token starts on.
9
+ * @property endLine - 1-based line the token ends on.
10
+ * @property start - Offset of the first character in the text.
11
+ * @property end - Offset behind the last character.
12
+ */
13
+ export interface SqlToken {
14
+ readonly kind: SqlTokenKind;
15
+ readonly value: string;
16
+ readonly line: number;
17
+ readonly endLine: number;
18
+ readonly start: number;
19
+ readonly end: number;
20
+ }
21
+ /**
22
+ * One comment of a SQL text.
23
+ *
24
+ * @property lines - The comment without its markers, one entry per line.
25
+ * @property line - 1-based line the comment starts on.
26
+ * @property endLine - 1-based line the comment ends on.
27
+ * @property alone - True when no token is in front of the comment on its line.
28
+ */
29
+ export interface SqlComment {
30
+ readonly lines: readonly string[];
31
+ readonly line: number;
32
+ readonly endLine: number;
33
+ readonly alone: boolean;
34
+ }
35
+ /**
36
+ * The tokens and the comments of a SQL text, from `tokenizeSql`.
37
+ *
38
+ * @property tokens - Tokens in text order.
39
+ * @property comments - Comments apart from the tokens, in text order.
40
+ */
41
+ export interface SqlTokens {
42
+ readonly tokens: readonly SqlToken[];
43
+ readonly comments: readonly SqlComment[];
44
+ }
45
+ /**
46
+ * Splits a SQL text into tokens and comments.
47
+ *
48
+ * @param source - The SQL text, as written in the file.
49
+ * @returns The tokens in text order, and the comments apart from them. Text that is no SQL becomes symbol tokens, so the function never fails.
50
+ */
51
+ export declare function tokenizeSql(source: string): SqlTokens;
@@ -0,0 +1,52 @@
1
+ /** Folder of a phase that holds its task files. */
2
+ export declare const TASKS_DIR = "tasks";
3
+ /** Folder of a plan that holds its decision files. */
4
+ export declare const DECISIONS_DIR = "decisions";
5
+ /** File at the root of the tree that holds its terms. */
6
+ export declare const VOCABULARY_FILE = "vocabulary.md";
7
+ /**
8
+ * A phase of the tree as its files lay it out.
9
+ *
10
+ * @property name - Folder name of the phase.
11
+ * @property file - Tree-relative path of `<plan>/<phase>/<phase>.md`.
12
+ * @property tasks - Tree-relative paths of the task files, sorted by name.
13
+ */
14
+ export interface PhaseFiles {
15
+ readonly name: string;
16
+ readonly file: string;
17
+ readonly tasks: readonly string[];
18
+ }
19
+ /**
20
+ * A plan of the tree as its files lay it out.
21
+ *
22
+ * @property name - Folder name of the plan.
23
+ * @property file - Tree-relative path of `<plan>/<plan>.md`.
24
+ * @property phases - Sorted by folder name, which is the order task-manager queues them in.
25
+ * @property decisions - Tree-relative paths of the decision files, sorted by name.
26
+ */
27
+ export interface PlanFiles {
28
+ readonly name: string;
29
+ readonly file: string;
30
+ readonly phases: readonly PhaseFiles[];
31
+ readonly decisions: readonly string[];
32
+ }
33
+ /**
34
+ * The task tree as its files lay it out.
35
+ *
36
+ * @property plans - Plans in folder order.
37
+ * @property vocabulary - Tree-relative path of the vocabulary, or `null` when the tree has none.
38
+ */
39
+ export interface TreeFiles {
40
+ readonly plans: readonly PlanFiles[];
41
+ readonly vocabulary: string | null;
42
+ }
43
+ /**
44
+ * @brief Sorts the files of a task tree into plans, phases, tasks and decisions by
45
+ * where they are: `<plan>/<plan>.md`, `<plan>/<phase>/<phase>.md`,
46
+ * `<plan>/<phase>/tasks/<id>.md` and `<plan>/decisions/<id>.md`. Index files
47
+ * and any other file are left out, since task-manager derives them.
48
+ *
49
+ * @param files - Paths relative to the root of the tree, in POSIX form.
50
+ * @returns The plans in folder order, each with its phases and decisions.
51
+ */
52
+ export declare function layoutTree(files: readonly string[]): TreeFiles;
@@ -0,0 +1,130 @@
1
+ import type { NodeRef } from '../../model';
2
+ import type { FileRenderer } from '../content';
3
+ import type { Source } from '../files';
4
+ import type { GlossaryPlanner } from '../glossary/planner';
5
+ import type { GraphBuilder } from '../graph/builder';
6
+ import type { ProseResolvers } from '../markdown/links';
7
+ import type { MarkdownRenderer } from '../markdown/renderer';
8
+ import type { Reporter } from '../reporter';
9
+ /**
10
+ * The task tree of one scan: the files below its directory, with paths relative to the scanned root.
11
+ *
12
+ * @property dir - Root-relative POSIX path of the tree, such as `docs/task-manager`.
13
+ */
14
+ export interface TaskTreeSource extends Source {
15
+ readonly dir: string;
16
+ }
17
+ /**
18
+ * @brief Adds the tasks section to the graph from a task-manager tree: one `plan`
19
+ * page per plan, one `phase` page per phase, one `task` entry per task file,
20
+ * a `decisions` page per plan with decision files, and the `vocabulary.md`
21
+ * of the tree as a glossary. Created by `RepositoryScanner` for every scan.
22
+ *
23
+ * What a plan, a phase or a task links to or names in inline code becomes a
24
+ * `names` edge, and every `depends_on` a `depends` edge. A file whose
25
+ * frontmatter fails its schema is reported and shown as a plain document.
26
+ *
27
+ * Holds the graph, the file renderer, the markdown renderer, the prose
28
+ * resolvers, the `GlossaryPlanner` for the vocabulary and the reporter for
29
+ * warnings.
30
+ *
31
+ * @example
32
+ * await new TaskPlanner(graph, files, markdown, resolvers, glossaries, reporter).plan(sections.tasks, input.tasks);
33
+ */
34
+ export declare class TaskPlanner {
35
+ private readonly graph;
36
+ private readonly files;
37
+ private readonly markdown;
38
+ private readonly resolvers;
39
+ private readonly glossaries;
40
+ private readonly reporter;
41
+ /**
42
+ * Creates a planner.
43
+ *
44
+ * @param graph - Graph the tasks section is added to.
45
+ * @param files - Renders the markdown pages of plans and phases.
46
+ * @param markdown - Renders the bodies of tasks and decisions.
47
+ * @param resolvers - Resolves the links and inline code of each page.
48
+ * @param glossaries - Adds the vocabulary file as a glossary.
49
+ * @param reporter - Receives a warning for every file that fails its schema and every `depends_on` that names nothing.
50
+ */
51
+ constructor(graph: GraphBuilder, files: FileRenderer, markdown: MarkdownRenderer, resolvers: ProseResolvers, glossaries: GlossaryPlanner, reporter: Reporter);
52
+ /**
53
+ * Adds every plan of the trees, with its phases, tasks and decisions.
54
+ *
55
+ * @param section - Node of the tasks section.
56
+ * @param trees - The task trees of the scan. Usually one, or none when the repository keeps no tasks.
57
+ */
58
+ plan(section: NodeRef, trees: readonly TaskTreeSource[]): Promise<void>;
59
+ /**
60
+ * Adds one plan with its phases and decisions.
61
+ *
62
+ * @param section - Node of the tasks section the plan goes under.
63
+ * @param tree - Task tree the plan's files are read from.
64
+ * @param plan - Files of the plan, from `layoutTree`.
65
+ * @param targets - Nodes that `depends_on` names can point at, filled as nodes are added.
66
+ * @param pending - Dependencies to resolve once every node exists.
67
+ */
68
+ private planPlan;
69
+ /**
70
+ * Adds one phase with its tasks.
71
+ *
72
+ * @param planRef - Node of the plan the phase belongs to.
73
+ * @param tree - Task tree the phase's files are read from.
74
+ * @param phase - Files of the phase, from `layoutTree`.
75
+ * @param phases - Phase nodes of this plan, by phase name.
76
+ * @param targets - Nodes that `depends_on` names can point at, filled as nodes are added.
77
+ * @param pending - Dependencies to resolve once every node exists.
78
+ */
79
+ private planPhase;
80
+ /**
81
+ * Adds the decision log of a plan: one `decisions` page for its folder and one `decision` entry per file.
82
+ *
83
+ * @param planRef - Node of the plan the log belongs to.
84
+ * @param tree - Task tree the decision files are read from.
85
+ * @param plan - Files of the plan, from `layoutTree`.
86
+ * @param paths - Tree-relative paths of the decision files.
87
+ */
88
+ private planDecisions;
89
+ /**
90
+ * Renders the page of a plan or a phase whose frontmatter passed its schema.
91
+ *
92
+ * @param self - Node the page is rendered for.
93
+ * @param read - The file that holds the page.
94
+ * @param meta - Parsed frontmatter of the file.
95
+ * @returns The content of the node: the rendered file, its title and summary, and where it stands.
96
+ */
97
+ private renderTracked;
98
+ /**
99
+ * Adds a tree file whose frontmatter failed its schema as a plain document.
100
+ *
101
+ * @param parent - Node the document goes under.
102
+ * @param read - The file to show as a document.
103
+ * @returns The node of the document.
104
+ */
105
+ private planDocument;
106
+ /**
107
+ * Checks the frontmatter of a file against its schema, and reports the file when it fails.
108
+ *
109
+ * @param schema - Schema the frontmatter must match.
110
+ * @param read - The file whose frontmatter is checked.
111
+ * @returns The parsed frontmatter, or `null` when it failed.
112
+ */
113
+ private parse;
114
+ /**
115
+ * Reads a file of the tree and splits off its frontmatter.
116
+ *
117
+ * @param tree - Task tree the file belongs to.
118
+ * @param treePath - Path of the file relative to the tree.
119
+ * @returns The file with its frontmatter, body and source text.
120
+ */
121
+ private read;
122
+ /**
123
+ * The paths of a tree file as the planners of the docs section take them.
124
+ *
125
+ * @param tree - Task tree the file belongs to.
126
+ * @param treePath - Path of the file relative to the tree.
127
+ * @returns The file with its root, root-relative path and display path.
128
+ */
129
+ private docFile;
130
+ }
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ /** Frontmatter of a plan file, `<plan>/<plan>.md`. Fields the site does not show are let through unread. */
3
+ export declare const PlanFrontmatterSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ title: z.ZodString;
6
+ priority: z.ZodEnum<{
7
+ critical: "critical";
8
+ high: "high";
9
+ low: "low";
10
+ medium: "medium";
11
+ }>;
12
+ depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
13
+ summary: z.ZodString;
14
+ status: z.ZodEnum<{
15
+ blocked: "blocked";
16
+ completed: "completed";
17
+ "in-progress": "in-progress";
18
+ "in-review": "in-review";
19
+ open: "open";
20
+ }>;
21
+ }, z.core.$strip>;
22
+ /** Parsed frontmatter of a plan file. */
23
+ export type PlanFrontmatter = z.infer<typeof PlanFrontmatterSchema>;
24
+ /** Frontmatter of a phase file, `<plan>/<phase>/<phase>.md`. task-manager spells the parallel flag `parrallel`. */
25
+ export declare const PhaseFrontmatterSchema: z.ZodObject<{
26
+ name: z.ZodString;
27
+ title: z.ZodString;
28
+ priority: z.ZodEnum<{
29
+ critical: "critical";
30
+ high: "high";
31
+ low: "low";
32
+ medium: "medium";
33
+ }>;
34
+ depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
35
+ summary: z.ZodString;
36
+ status: z.ZodEnum<{
37
+ blocked: "blocked";
38
+ completed: "completed";
39
+ "in-progress": "in-progress";
40
+ "in-review": "in-review";
41
+ open: "open";
42
+ }>;
43
+ parrallel: z.ZodOptional<z.ZodBoolean>;
44
+ parallel: z.ZodOptional<z.ZodBoolean>;
45
+ }, z.core.$strip>;
46
+ /** Parsed frontmatter of a phase file. */
47
+ export type PhaseFrontmatter = z.infer<typeof PhaseFrontmatterSchema>;
48
+ /** Frontmatter of a task file, `<plan>/<phase>/tasks/<id>.md`. */
49
+ export declare const TaskFrontmatterSchema: z.ZodObject<{
50
+ id: z.ZodString;
51
+ title: z.ZodString;
52
+ package: z.ZodString;
53
+ priority: z.ZodEnum<{
54
+ critical: "critical";
55
+ high: "high";
56
+ low: "low";
57
+ medium: "medium";
58
+ }>;
59
+ depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
60
+ summary: z.ZodString;
61
+ complexity: z.ZodOptional<z.ZodNumber>;
62
+ status: z.ZodEnum<{
63
+ blocked: "blocked";
64
+ completed: "completed";
65
+ "in-progress": "in-progress";
66
+ "in-review": "in-review";
67
+ open: "open";
68
+ }>;
69
+ }, z.core.$strip>;
70
+ /** Parsed frontmatter of a task file. */
71
+ export type TaskFrontmatter = z.infer<typeof TaskFrontmatterSchema>;
72
+ /** Frontmatter of a decision file in a plan's `decisions/` folder. */
73
+ export declare const DecisionFrontmatterSchema: z.ZodObject<{
74
+ id: z.ZodString;
75
+ title: z.ZodString;
76
+ status: z.ZodString;
77
+ date: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodDate, z.ZodTransform<string, Date>>]>>;
78
+ supersedes: z.ZodOptional<z.ZodString>;
79
+ }, z.core.$strip>;
80
+ /** Parsed frontmatter of a decision file. */
81
+ export type DecisionFrontmatter = z.infer<typeof DecisionFrontmatterSchema>;
82
+ /**
83
+ * Describes why a frontmatter block failed its schema, for a warning.
84
+ *
85
+ * @param error - The error of a failed `safeParse`.
86
+ * @returns The issues joined, such as `status: Invalid option; summary: Required`.
87
+ */
88
+ export declare function describeIssues(error: z.ZodError): string;
@@ -0,0 +1,14 @@
1
+ /** Turns a text into a lowercase, hyphen-separated identifier that is safe in a URL path segment, or `untitled`. */
2
+ export declare function slugify(value: string): string;
3
+ /** Returns `base`, or `base-2`, `base-3`… when `base` is already in `taken`, and adds the result to `taken`. */
4
+ export declare function uniqueId(base: string, taken: Set<string>, separator?: string): string;
5
+ /** Removes the indentation shared by every non-blank line. */
6
+ export declare function dedent(text: string): string;
7
+ /** Dedents and drops leading and trailing blank lines. */
8
+ export declare function trimBlock(text: string): string;
9
+ /** Escapes `&`, `<`, `>` and `"` for HTML text and attribute values. */
10
+ export declare function escapeHtml(value: string): string;
11
+ /** Converts a name in any case to camelCase, such as `user_id` to `userId`. */
12
+ export declare function toCamelCase(name: string): string;
13
+ /** Converts a name in any case to snake_case, such as `userId` to `user_id`. */
14
+ export declare function toSnakeCase(name: string): string;
package/package.json CHANGED
@@ -1,6 +1,106 @@
1
1
  {
2
2
  "name": "@g3nomaly/analyze",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Turns a repository into one offline HTML documentation site, and queries the same linked model from the terminal and from hooks.",
5
+ "keywords": [
6
+ "documentation",
7
+ "docs",
8
+ "generator",
9
+ "cli",
10
+ "bun",
11
+ "tree-sitter",
12
+ "skills",
13
+ "tasks",
14
+ "openapi",
15
+ "json-schema",
16
+ "sqlite",
17
+ "semantic-search"
18
+ ],
19
+ "type": "module",
20
+ "bin": {
21
+ "g3n-analyze": "./dist/cli.js"
22
+ },
23
+ "module": "./src/index.ts",
24
+ "exports": {
25
+ ".": "./src/index.ts",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "engines": {
32
+ "bun": ">=1.2.21"
33
+ },
34
+ "scripts": {
35
+ "build": "bun run scripts/build.ts",
36
+ "typecheck": "tsc --noEmit",
37
+ "test": "bun test tests/unit",
38
+ "test:integration": "bun run build && bun test tests/integration",
39
+ "analyze": "bun run src/cli/index.ts",
40
+ "docs": "bun run build && bun dist/cli.js create_docs"
41
+ },
42
+ "dependencies": {
43
+ "@g3nomaly/core": "^0.3.2",
44
+ "@t3-oss/env-core": "^0.13.11",
45
+ "hast-util-to-string": "^3.0.1",
46
+ "rehype-parse": "^9.0.1",
47
+ "rehype-remark": "^10.0.1",
48
+ "rehype-slug": "^6.0.0",
49
+ "rehype-stringify": "^10.0.1",
50
+ "remark-gfm": "^4.0.1",
51
+ "remark-parse": "^11.0.0",
52
+ "remark-rehype": "^11.1.2",
53
+ "remark-stringify": "^11.0.0",
54
+ "shiki": "^4.5.0",
55
+ "unified": "^11.0.5",
56
+ "unist-util-visit": "^5.1.0",
57
+ "web-tree-sitter": "^0.27.0",
58
+ "zod": "^4.6.5"
59
+ },
60
+ "devDependencies": {
61
+ "@g3nomaly/ui": "^0.3.1",
62
+ "@tanstack/react-router": "^1.170.41",
63
+ "@tanstack/react-store": "^0.11.2",
64
+ "@tree-sitter-grammars/tree-sitter-kotlin": "^1.1.0",
65
+ "@types/bun": "^1.4.2",
66
+ "@types/d3-drag": "^3.0.7",
67
+ "@types/d3-force": "^3.0.10",
68
+ "@types/d3-selection": "^3.0.12",
69
+ "@types/d3-zoom": "^3.0.9",
70
+ "@types/hast": "^3.0.5",
71
+ "@types/mdast": "^4.0.4",
72
+ "@types/react": "^19.3.0",
73
+ "@types/react-dom": "^19.3.0",
74
+ "@vscode/tree-sitter-wasm": "^0.3.1",
75
+ "bun-plugin-tailwind": "^0.1.2",
76
+ "class-variance-authority": "^0.7.1",
77
+ "clsx": "^2.1.1",
78
+ "cmdk": "^1.1.1",
79
+ "d3-drag": "^3.0.0",
80
+ "d3-force": "^3.0.0",
81
+ "d3-selection": "^3.0.0",
82
+ "d3-zoom": "^3.0.0",
83
+ "lucide-react": "^1.52.0",
84
+ "radix-ui": "^1.7.0",
85
+ "react": "^19.3.0",
86
+ "react-dom": "^19.3.0",
87
+ "shadcn": "^4.21.3",
88
+ "tailwind-merge": "^3.7.0",
89
+ "tailwindcss": "^4.3.3",
90
+ "tree-sitter-c": "^0.24.1",
91
+ "tree-sitter-scala": "^0.24.0",
92
+ "tw-animate-css": "^1.4.0",
93
+ "typescript": "^7.0.2"
94
+ },
95
+ "license": "Elastic-2.0",
96
+ "publishConfig": {
97
+ "access": "public",
98
+ "exports": {
99
+ ".": {
100
+ "types": "./dist/index.d.ts",
101
+ "default": "./dist/index.js"
102
+ },
103
+ "./package.json": "./package.json"
104
+ }
105
+ }
106
+ }