@ttsc/graph 0.18.4 → 0.19.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.
- package/README.md +231 -37
- package/lib/TtscGraphApplication.d.ts +1 -1
- package/lib/TtscGraphApplication.js +50 -17
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +20 -1
- package/lib/index.js.map +1 -1
- package/lib/model/TtscGraphMemory.js +80 -22
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphSession.js +92 -138
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/loadGraph.js +91 -138
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/resolveGraphBinary.d.ts +4 -2
- package/lib/resolveGraphBinary.js +7 -3
- package/lib/resolveGraphBinary.js.map +1 -1
- package/lib/server/createServer.d.ts +16 -9
- package/lib/server/createServer.js +286 -190
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/exportSurface.d.ts +26 -0
- package/lib/server/exportSurface.js +44 -0
- package/lib/server/exportSurface.js.map +1 -0
- package/lib/server/resolveHandle.d.ts +26 -1
- package/lib/server/resolveHandle.js +124 -4
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +74 -0
- package/lib/server/resultAudit.js +110 -0
- package/lib/server/resultAudit.js.map +1 -0
- package/lib/server/resultNext.d.ts +9 -0
- package/lib/server/resultNext.js +11 -0
- package/lib/server/resultNext.js.map +1 -0
- package/lib/server/runDetails.d.ts +15 -3
- package/lib/server/runDetails.js +105 -23
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.d.ts +2 -1
- package/lib/server/runEntrypoints.js +17 -10
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.d.ts +2 -1
- package/lib/server/runLookup.js +21 -9
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runOverview.d.ts +2 -1
- package/lib/server/runOverview.js +5 -4
- package/lib/server/runOverview.js.map +1 -1
- package/lib/server/runTour.d.ts +2 -1
- package/lib/server/runTour.js +707 -331
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +2 -1
- package/lib/server/runTrace.js +234 -54
- package/lib/server/runTrace.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +122 -118
- package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
- package/lib/structures/ITtscGraphDetails.d.ts +51 -43
- package/lib/structures/ITtscGraphDump.d.ts +32 -8
- package/lib/structures/ITtscGraphEdge.d.ts +4 -6
- package/lib/structures/ITtscGraphEntrypoints.d.ts +10 -27
- package/lib/structures/ITtscGraphEscape.d.ts +6 -16
- package/lib/structures/ITtscGraphEvidence.d.ts +5 -8
- package/lib/structures/ITtscGraphLookup.d.ts +9 -20
- package/lib/structures/ITtscGraphNext.d.ts +10 -7
- package/lib/structures/ITtscGraphNode.d.ts +17 -8
- package/lib/structures/ITtscGraphOverview.d.ts +10 -14
- package/lib/structures/ITtscGraphSpan.d.ts +29 -0
- package/lib/structures/{ITtscGraphDiagnostic.js → ITtscGraphSpan.js} +1 -1
- package/lib/structures/ITtscGraphSpan.js.map +1 -0
- package/lib/structures/ITtscGraphTour.d.ts +65 -23
- package/lib/structures/ITtscGraphTrace.d.ts +72 -49
- package/lib/structures/TtscGraphEdgeKind.d.ts +7 -1
- package/lib/structures/index.d.ts +1 -1
- package/lib/structures/index.js +1 -1
- package/lib/structures/index.js.map +1 -1
- package/lib/view.js +3 -1
- package/lib/view.js.map +1 -1
- package/package.json +4 -4
- package/src/TtscGraphApplication.ts +58 -27
- package/src/index.ts +19 -1
- package/src/model/TtscGraphMemory.ts +86 -22
- package/src/model/TtscGraphSession.ts +5 -1
- package/src/model/loadGraph.ts +3 -1
- package/src/resolveGraphBinary.ts +7 -3
- package/src/server/createServer.ts +24 -17
- package/src/server/exportSurface.ts +40 -0
- package/src/server/resolveHandle.ts +141 -4
- package/src/server/resultAudit.ts +109 -0
- package/src/server/resultNext.ts +22 -0
- package/src/server/runDetails.ts +112 -28
- package/src/server/runEntrypoints.ts +26 -17
- package/src/server/runLookup.ts +29 -18
- package/src/server/runOverview.ts +9 -10
- package/src/server/runTour.ts +764 -363
- package/src/server/runTrace.ts +265 -71
- package/src/structures/ITtscGraphApplication.ts +124 -118
- package/src/structures/ITtscGraphDecorator.ts +4 -7
- package/src/structures/ITtscGraphDetails.ts +60 -46
- package/src/structures/ITtscGraphDump.ts +37 -8
- package/src/structures/ITtscGraphEdge.ts +4 -6
- package/src/structures/ITtscGraphEntrypoints.ts +10 -30
- package/src/structures/ITtscGraphEscape.ts +6 -19
- package/src/structures/ITtscGraphEvidence.ts +5 -8
- package/src/structures/ITtscGraphLookup.ts +9 -22
- package/src/structures/ITtscGraphNext.ts +10 -7
- package/src/structures/ITtscGraphNode.ts +18 -8
- package/src/structures/ITtscGraphOverview.ts +10 -17
- package/src/structures/ITtscGraphSpan.ts +33 -0
- package/src/structures/ITtscGraphTour.ts +70 -28
- package/src/structures/ITtscGraphTrace.ts +82 -51
- package/src/structures/TtscGraphEdgeKind.ts +7 -0
- package/src/structures/index.ts +1 -1
- package/src/view.ts +3 -1
- package/lib/server/accessAliases.d.ts +0 -8
- package/lib/server/accessAliases.js +0 -53
- package/lib/server/accessAliases.js.map +0 -1
- package/lib/server/resultGuide.d.ts +0 -3
- package/lib/server/resultGuide.js +0 -16
- package/lib/server/resultGuide.js.map +0 -1
- package/lib/structures/ITtscGraphDiagnostic.d.ts +0 -27
- package/lib/structures/ITtscGraphDiagnostic.js.map +0 -1
- package/src/server/accessAliases.ts +0 -55
- package/src/server/resultGuide.ts +0 -20
- package/src/structures/ITtscGraphDiagnostic.ts +0 -34
package/src/server/runLookup.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
2
|
import { ITtscGraphLookup } from "../structures/ITtscGraphLookup";
|
|
3
3
|
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
4
|
+
import { exportFanIn } from "./exportSurface";
|
|
4
5
|
import { isExternalNode, isSupportPath } from "./pathPolicy";
|
|
5
|
-
import {
|
|
6
|
+
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
6
7
|
import { decoratorsOf, signatureOf } from "./runDetails";
|
|
7
8
|
|
|
8
9
|
// One file should not crowd out the rest of the ranking, so cap hits per file.
|
|
@@ -20,7 +21,7 @@ const MAX_LIMIT = 6;
|
|
|
20
21
|
export function runLookup(
|
|
21
22
|
graph: TtscGraphMemory,
|
|
22
23
|
props: ITtscGraphLookup.IRequest,
|
|
23
|
-
): ITtscGraphLookup {
|
|
24
|
+
): IRunnerOutput<ITtscGraphLookup> {
|
|
24
25
|
const terms = subwords(props.query);
|
|
25
26
|
const codeTerms = exactCodeTerms(props.query);
|
|
26
27
|
const requestedKinds = requestedSymbolKinds(props.query);
|
|
@@ -30,14 +31,13 @@ export function runLookup(
|
|
|
30
31
|
const includeExternal = props.includeExternal === true;
|
|
31
32
|
if (terms.length === 0)
|
|
32
33
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
result: {
|
|
35
|
+
type: "lookup",
|
|
36
|
+
hits: [],
|
|
37
|
+
},
|
|
35
38
|
next: resultNext(
|
|
36
39
|
"clarify",
|
|
37
|
-
"
|
|
38
|
-
),
|
|
39
|
-
guide: resultGuide(
|
|
40
|
-
"No symbol matched; answer that the graph did not resolve this name or ask for a more concrete symbol.",
|
|
40
|
+
"The query carries no searchable terms, so no symbol could be matched.",
|
|
41
41
|
),
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -92,16 +92,20 @@ export function runLookup(
|
|
|
92
92
|
if (sig !== undefined) hit.signature = sig;
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
result: {
|
|
96
|
+
type: "lookup",
|
|
97
|
+
hits,
|
|
98
|
+
},
|
|
99
|
+
next:
|
|
100
|
+
hits.length === 0
|
|
101
|
+
? resultNext(
|
|
102
|
+
"outside",
|
|
103
|
+
"No symbol matched, so the graph did not resolve this name.",
|
|
104
|
+
)
|
|
105
|
+
: resultNext(
|
|
106
|
+
"answer",
|
|
107
|
+
"The ranked hits and their signatures resolve the name.",
|
|
108
|
+
),
|
|
105
109
|
};
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -168,6 +172,13 @@ function scoreNode(
|
|
|
168
172
|
const fan = degree(graph, node.id);
|
|
169
173
|
score += Math.min(8, Math.log2(1 + fan) * 2);
|
|
170
174
|
|
|
175
|
+
// How many modules put this symbol on the wire. Two symbols can match a name
|
|
176
|
+
// equally well while one is what a consumer imports and the other is a leftover
|
|
177
|
+
// major the package still ships behind a subpath; the re-export chain is what
|
|
178
|
+
// tells them apart, so it breaks the tie.
|
|
179
|
+
const surface = exportFanIn(graph, node.id);
|
|
180
|
+
if (surface > 0) score *= 1 + Math.min(0.4, Math.log2(1 + surface) * 0.14);
|
|
181
|
+
|
|
171
182
|
// Dampen what is rarely the intended target.
|
|
172
183
|
if (node.ignored) score *= 0.3;
|
|
173
184
|
if (isTestFile(node.file)) score *= 0.7;
|
|
@@ -2,7 +2,7 @@ import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
|
2
2
|
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
3
3
|
import { ITtscGraphOverview } from "../structures/ITtscGraphOverview";
|
|
4
4
|
import { isPublicApiNoisePath, isSupportPath } from "./pathPolicy";
|
|
5
|
-
import {
|
|
5
|
+
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
6
6
|
|
|
7
7
|
/** Edges that express nesting/packaging, not code dependency. */
|
|
8
8
|
const STRUCTURAL_KINDS = new Set<string>(["contains", "exports", "imports"]);
|
|
@@ -17,7 +17,7 @@ const STRUCTURAL_KINDS = new Set<string>(["contains", "exports", "imports"]);
|
|
|
17
17
|
export function runOverview(
|
|
18
18
|
graph: TtscGraphMemory,
|
|
19
19
|
props: ITtscGraphOverview.IRequest,
|
|
20
|
-
): ITtscGraphOverview {
|
|
20
|
+
): IRunnerOutput<ITtscGraphOverview> {
|
|
21
21
|
const aspect = props.aspect ?? "all";
|
|
22
22
|
const want = (a: ITtscGraphOverview.IRequest["aspect"]): boolean =>
|
|
23
23
|
aspect === "all" || aspect === a;
|
|
@@ -38,18 +38,17 @@ export function runOverview(
|
|
|
38
38
|
edges: graph.edges.length,
|
|
39
39
|
byKind,
|
|
40
40
|
},
|
|
41
|
-
next: resultNext(
|
|
42
|
-
"answer",
|
|
43
|
-
"Counts, layers, hotspots, and public API are sufficient for broad orientation.",
|
|
44
|
-
),
|
|
45
|
-
guide: resultGuide(
|
|
46
|
-
"Use counts, layers, hotspots, and public API as a broad orientation map. Do not expand it into file reads unless the user needs exact source body text.",
|
|
47
|
-
),
|
|
48
41
|
};
|
|
49
42
|
if (want("layers")) result.layers = layers(graph);
|
|
50
43
|
if (want("hotspots")) result.hotspots = hotspots(graph);
|
|
51
44
|
if (want("publicApi")) result.publicApi = publicApi(graph);
|
|
52
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
result,
|
|
47
|
+
next: resultNext(
|
|
48
|
+
"answer",
|
|
49
|
+
"Counts, layers, hotspots, and public API are what the graph holds about the project's shape.",
|
|
50
|
+
),
|
|
51
|
+
};
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
/** Folder-level layering: how source and its export surface spread by directory. */
|