@g3nomaly/analyze 0.1.6 → 0.1.7

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.
package/README.md CHANGED
@@ -52,7 +52,11 @@ Hits that match the same way, with the same kind, type, title, summary, score an
52
52
 
53
53
  When nothing matches, `search` lists up to three weak matches by meaning instead, under a note and with `weak: true` in the JSON. Rewording the query often finds a better one. Output is markdown, or JSON with `--json`. `--from analyze_out/index.html` queries a built site without the repository. `g3n-analyze --help` lists every option, node kind, section and edge kind.
54
54
 
55
- `refs --depth <n>` follows the edges `n` hops, one hop at a time in each direction, and prints each hop indented under the reference it follows. A node is listed once. `--edge`, `--incoming` and `--outgoing` apply at every hop; `--kind` and `--section` only pick the node to start from. `refs` lists at most 50 references over every hop, or `-n`, and says how many more it left out. `path <from> <to>` follows edges the way they point, so `path a b` and `path b a` differ; `--edge` keeps it to some kinds. A name with spaces goes in quotes.
55
+ `refs --depth <n>` follows the edges `n` hops, one hop at a time in each direction, and prints each hop indented under the reference it follows. A node is listed once. `--edge`, `--incoming` and `--outgoing` apply at every hop; `--kind` and `--section` only pick the node to start from. `refs` lists at most 50 references over every hop, or `-n`, and says how many more it left out. `path <from> <to>` follows edges the way they point, so `path a b` and `path b a` differ; `--edge` keeps it to some kinds. Without `--edge` it follows every kind but `mentions`, the links descriptions make; `--include-mentions` follows those too, and of equally short chains the one with the fewest `mentions` steps still wins. A name with spaces goes in quotes.
56
+
57
+ A call, a function passed on and an import say where they are made: `calls (add.ts:86, 112)` is a call on lines 86 and 112 of `add.ts`, the file of the node the edge starts at. In the JSON, such a reference has `location`, with the `path` of that file and its `lines`; any other reference has `location: null`. The links to one node print on one line, `calls (app.ts:7), passes (app.ts:9): function run`, and a heading counts the lines under it.
58
+
59
+ `refs --level files` lists the links between the file of the node and other files, the way the files level of the graph page draws them: every link of the file or of an entry in it, to another file or an entry in it, counts for that file. These are no links of their own. The default, `--level entries`, lists the links as they are stored.
56
60
 
57
61
  The commands exit with 0 when they answer, also for a search that finds nothing, with 1 for a node that does not exist, a name that fits several nodes, a `path` with no chain, or a repository or site that cannot be read, and with 2 for a call that is not valid, such as an unknown flag.
58
62
 
@@ -64,7 +68,7 @@ A **community** is a group of nodes that link to each other more than to the res
64
68
 
65
69
  ### How code links
66
70
 
67
- - **Imports**: C and C++ `#include`, JavaScript and TypeScript imports, and Python imports link to the file of the repository they name. An include resolves next to the including file, then against every file whose path ends with it, the closest winning. A TypeScript import resolves a relative path, a package of the repository by name (`@scope/core`), or a path alias (`@/lib/api`). A header or package from outside the repository links to nothing.
71
+ - **Imports**: an import of a whole file links to that file: a C or C++ `#include`, a Python `import a.b`, and in JavaScript and TypeScript `import './x'`, `import * as x`, a default import, `export * from` and `require`. An import by name links to each class, function or type it names, through any `export … from` files in between, and not to the file: `import { recordedHashes } from "../../installer"` links to `recordedHashes` in `installer/classify.ts`, which `installer/index.ts` re-exports. Python's `from a import b` does the same for a `b` that is no module. A name that is no node, such as a constant, links to the file the import names. An include resolves next to the including file, then against every file whose path ends with it, the closest winning. A TypeScript import resolves a relative path, a package of the repository by name (`@scope/core`), or a path alias (`@/lib/api`). A header or package from outside the repository links to nothing. The files level of the graph page and of `graph` draws the links of a file to the entries of another file as one arrow between the files.
68
72
  - **What a file sees**: in C, C++, JavaScript, TypeScript and Python, a file sees itself and the files it imports, directly or through other files. A type name or a call only links to a declaration in a file it sees, so a common name never links across the repository. In the other languages every file is seen, and a type name links to the closest declaration of that name.
69
73
  - **Types**: a qualified C++ name such as `geo::Point` only links to a `Point` inside `geo`. A type declared in a C or C++ source file is seen only in that file.
70
74
  - **Calls**: a call links when it names one function: by name, through a namespace or type (`geo::distance()`, `Timer.once()`), through `this` or `self`, or through a parameter or field whose declared type is known. A call through a local variable, a module alias such as `helpers.go()`, or any other expression links nowhere, since its type is unknown. A bare call inside a JavaScript, TypeScript or Python method never means a method of its own class. A C++ method declared in a header and defined in a source file is called at its declaration. Only the calls inside a function or method link: code at the top level of a file, such as the callbacks a CLI registers there, belongs to no function.
@@ -6,7 +6,9 @@ import type { NodeFilter, NodeSummary, Reference, Retriever } from '../retrieval
6
6
  *
7
7
  * @property start - Id, path or name of the node the chain starts at. Not `from`, which names a site to read.
8
8
  * @property end - Id, path or name of the node the chain ends at.
9
- * @property edges - Only edges of these kinds. Empty or absent follows every kind.
9
+ * @property edges - Only edges of these kinds. Empty or absent follows every kind but `mentions`.
10
+ * @property includeMentions - Also follow `mentions`, the links descriptions make, when `edges` is empty. Of the
11
+ * chains that are equally short, the one with the fewest `mentions` steps still wins.
10
12
  */
11
13
  declare const pathSchema: z.ZodPipe<z.ZodObject<{
12
14
  onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
@@ -68,6 +70,7 @@ declare const pathSchema: z.ZodPipe<z.ZodObject<{
68
70
  uses: "uses";
69
71
  writes: "writes";
70
72
  }>>>>;
73
+ includeMentions: z.ZodOptional<z.ZodBoolean>;
71
74
  }, z.core.$strict>, z.ZodTransform<{
72
75
  source: import("./source").BundleSource;
73
76
  reporter: import("../scanner").Reporter;
@@ -76,6 +79,7 @@ declare const pathSchema: z.ZodPipe<z.ZodObject<{
76
79
  end: string;
77
80
  filter: NodeFilter;
78
81
  kinds: readonly ("affects" | "calls" | "depends" | "extends" | "imports" | "mentions" | "names" | "passes" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[];
82
+ includeMentions: boolean;
79
83
  };
80
84
  }, {
81
85
  onWarning?: import("./options").WarningHandler | undefined;
@@ -92,6 +96,7 @@ declare const pathSchema: z.ZodPipe<z.ZodObject<{
92
96
  start: string;
93
97
  end: string;
94
98
  edges?: readonly ("affects" | "calls" | "depends" | "extends" | "imports" | "mentions" | "names" | "passes" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[] | undefined;
99
+ includeMentions?: boolean | undefined;
95
100
  }>>;
96
101
  /** Options of `path`: the two nodes, the edges to follow, and the bundle to read. */
97
102
  export type PathOptions = z.input<typeof pathSchema>;
@@ -101,13 +106,15 @@ export type PathOptions = z.input<typeof pathSchema>;
101
106
  * @property start - Id, path or name of the node the chain starts at.
102
107
  * @property end - Id, path or name of the node the chain ends at.
103
108
  * @property filter - Narrows both names to one node each.
104
- * @property kinds - Edge kinds to follow. Empty follows every kind.
109
+ * @property kinds - Edge kinds to follow. Empty follows every kind but `mentions`, unless `includeMentions` is set.
110
+ * @property includeMentions - Whether an empty `kinds` follows `mentions` too.
105
111
  */
106
112
  export interface PathRequest {
107
113
  readonly start: string;
108
114
  readonly end: string;
109
115
  readonly filter: NodeFilter;
110
116
  readonly kinds: readonly EdgeKind[];
117
+ readonly includeMentions: boolean;
111
118
  }
112
119
  /**
113
120
  * What `path` finds. The CLI prints it with `path --json`.
@@ -9,6 +9,8 @@ import { type NodeFilter, type NodeSummary, type Retriever, type Walk, type Walk
9
9
  * @property edges - Only edges of these kinds. Empty or absent keeps every kind.
10
10
  * @property depth - Hops to follow from the node. Default: 1, the node's own references.
11
11
  * @property limit - Most references to list, every hop and both directions together. Default: 50.
12
+ * @property level - `entries` for the stored links, `files` for the links between the files that hold their ends,
13
+ * from the file of the node. Default: `entries`.
12
14
  */
13
15
  declare const refsSchema: z.ZodPipe<z.ZodObject<{
14
16
  onWarning: z.ZodOptional<z.ZodCustom<import("./options").WarningHandler, import("./options").WarningHandler>>;
@@ -73,6 +75,10 @@ declare const refsSchema: z.ZodPipe<z.ZodObject<{
73
75
  }>>>>;
74
76
  depth: z.ZodOptional<z.ZodNumber>;
75
77
  limit: z.ZodOptional<z.ZodNumber>;
78
+ level: z.ZodOptional<z.ZodEnum<{
79
+ entries: "entries";
80
+ files: "files";
81
+ }>>;
76
82
  }, z.core.$strict>, z.ZodTransform<{
77
83
  source: import("./source").BundleSource;
78
84
  reporter: import("../scanner").Reporter;
@@ -84,6 +90,7 @@ declare const refsSchema: z.ZodPipe<z.ZodObject<{
84
90
  kinds: readonly ("affects" | "calls" | "depends" | "extends" | "imports" | "mentions" | "names" | "passes" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[];
85
91
  depth: number;
86
92
  limit: number;
93
+ level: "entries" | "files";
87
94
  };
88
95
  };
89
96
  }, {
@@ -104,6 +111,7 @@ declare const refsSchema: z.ZodPipe<z.ZodObject<{
104
111
  edges?: readonly ("affects" | "calls" | "depends" | "extends" | "imports" | "mentions" | "names" | "passes" | "reads" | "references" | "returns" | "throws" | "type" | "uses" | "writes")[] | undefined;
105
112
  depth?: number | undefined;
106
113
  limit?: number | undefined;
114
+ level?: "entries" | "files" | undefined;
107
115
  }>>;
108
116
  /** Options of `refs`: the node, which links to follow and how far, and the bundle to read. */
109
117
  export type RefsOptions = z.input<typeof refsSchema>;
@@ -122,7 +130,7 @@ export interface RefsRequest {
122
130
  /**
123
131
  * What `refs` finds. The CLI prints it with `refs --json`.
124
132
  *
125
- * @property node - The node the references are of.
133
+ * @property node - The node the references are of: the file of the target at the `files` level.
126
134
  */
127
135
  export interface RefsResult extends Walk {
128
136
  readonly node: NodeSummary;