@ttsc/graph 0.18.3 → 0.19.0
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 -36
- package/lib/TtscGraphApplication.d.ts +4 -3
- package/lib/TtscGraphApplication.js +54 -19
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/index.d.ts +9 -4
- package/lib/index.js +24 -5
- 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.d.ts +36 -0
- package/lib/model/TtscGraphSession.js +457 -0
- package/lib/model/TtscGraphSession.js.map +1 -0
- package/lib/model/loadGraph.d.ts +3 -3
- package/lib/model/loadGraph.js +94 -141
- 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/server/startServer.d.ts +3 -2
- package/lib/server/startServer.js +13 -7
- package/lib/server/startServer.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +122 -114
- package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
- package/lib/structures/ITtscGraphDetails.d.ts +51 -43
- package/lib/structures/ITtscGraphDump.d.ts +36 -11
- 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 +66 -31
- package/src/index.ts +23 -5
- package/src/model/TtscGraphMemory.ts +86 -22
- package/src/model/TtscGraphSession.ts +204 -0
- package/src/model/loadGraph.ts +6 -4
- 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/server/startServer.ts +13 -8
- package/src/structures/ITtscGraphApplication.ts +124 -114
- package/src/structures/ITtscGraphDecorator.ts +4 -7
- package/src/structures/ITtscGraphDetails.ts +60 -46
- package/src/structures/ITtscGraphDump.ts +41 -11
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
|
|
2
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
3
2
|
/** The compact dependency or caller flow returned from a selected start symbol. */
|
|
4
3
|
export interface ITtscGraphTrace {
|
|
5
4
|
/** Discriminator for dependency tracing. */
|
|
@@ -12,86 +11,119 @@ export interface ITtscGraphTrace {
|
|
|
12
11
|
hops: ITtscGraphTrace.IHop[];
|
|
13
12
|
/** Unique nodes reached (excluding the start), each with its depth and roles. */
|
|
14
13
|
reached: ITtscGraphTrace.INode[];
|
|
15
|
-
/** True when the trace hit
|
|
14
|
+
/** True when the trace hit its node or depth cap; the returned flow stands. */
|
|
16
15
|
truncated: boolean;
|
|
17
16
|
/** The resolved `to` target, when a path was requested. */
|
|
18
17
|
target?: ITtscGraphTrace.INode;
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `from`.
|
|
19
|
+
* Ordered dependency path from `from` to `to` when `to` was given (`from`
|
|
20
|
+
* first, `to` last), empty when `to` is unreachable.
|
|
23
21
|
*/
|
|
24
22
|
path?: ITtscGraphTrace.INode[];
|
|
25
23
|
/** Compact hop summaries preserving node names and edge evidence, capped. */
|
|
26
24
|
steps?: string[];
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Symbols both ends touch, when no call path runs between them.
|
|
27
|
+
*
|
|
28
|
+
* Nothing calls across the gap because in an event-driven codebase nothing
|
|
29
|
+
* does: a handler registers a listener on an emitter, the emitter's `emit()`
|
|
30
|
+
* runs whatever a registration put in an array, and no call edge crosses that
|
|
31
|
+
* array. But both ends touch the emitter, and that is an edge, not a guess —
|
|
32
|
+
* Excalidraw's pointer handler and its store's emit both reference
|
|
33
|
+
* `Store.onDurableIncrementEmitter`, which is exactly the seam the call graph
|
|
34
|
+
* cannot walk.
|
|
35
|
+
*
|
|
36
|
+
* A junction is not a path. It is the symbol to look at next, and the edges
|
|
37
|
+
* that say why.
|
|
38
|
+
*/
|
|
39
|
+
junctions?: ITtscGraphTrace.IJunction[];
|
|
31
40
|
/** When `from` was an ambiguous name, the matches to disambiguate with. */
|
|
32
41
|
candidates?: ITtscGraphTrace.INode[];
|
|
33
42
|
}
|
|
34
43
|
export declare namespace ITtscGraphTrace {
|
|
44
|
+
/** A symbol both ends of an unreachable path touch, and how each touches it. */
|
|
45
|
+
interface IJunction {
|
|
46
|
+
/** Stable node id: trace or inspect this symbol to cross the seam. */
|
|
47
|
+
id: string;
|
|
48
|
+
/** Qualified symbol name when available, otherwise the simple name. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Declaration kind (`variable`, `method`, `class`, ...). */
|
|
51
|
+
kind: string;
|
|
52
|
+
/** Project-relative path of the file that declares it. */
|
|
53
|
+
file: string;
|
|
54
|
+
/** 1-based declaration line, when known. */
|
|
55
|
+
line?: number;
|
|
56
|
+
/** How the start reaches it: the edge kind, and where that edge sits. */
|
|
57
|
+
fromStart: IJunctionEdge;
|
|
58
|
+
/** How the target reaches it, or is reached from it. */
|
|
59
|
+
fromTarget: IJunctionEdge;
|
|
60
|
+
}
|
|
61
|
+
/** One edge between an end of the requested path and the junction. */
|
|
62
|
+
interface IJunctionEdge {
|
|
63
|
+
/** `calls`, `accesses`, `instantiates`, `type_ref`, ... */
|
|
64
|
+
kind: string;
|
|
65
|
+
/** True when the end is the edge's source, false when it is the target. */
|
|
66
|
+
outgoing: boolean;
|
|
67
|
+
/** Where the reference sits in source. */
|
|
68
|
+
evidence?: ITtscGraphEvidence;
|
|
69
|
+
}
|
|
35
70
|
/** Where and how far to trace dependency flow. */
|
|
36
71
|
interface IRequest {
|
|
37
72
|
/** Discriminator for dependency tracing. */
|
|
38
73
|
type: "trace";
|
|
39
74
|
/**
|
|
40
|
-
* Where to start: a node id
|
|
41
|
-
*
|
|
42
|
-
*
|
|
75
|
+
* Where to start: a node id, a simple symbol name, or a dotted member
|
|
76
|
+
* (`OrderService.create`). An ambiguous name returns its candidates instead
|
|
77
|
+
* of a trace.
|
|
43
78
|
*/
|
|
44
79
|
from: string;
|
|
45
80
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
81
|
+
* Target symbol (node id, simple name, or dotted member). When given, the
|
|
82
|
+
* tool returns the dependency path from `from` to it, the one-call answer
|
|
83
|
+
* for "how does A reach B". Prefer this path mode whenever both ends are
|
|
84
|
+
* known.
|
|
50
85
|
*/
|
|
51
86
|
to?: string;
|
|
52
87
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
88
|
+
* Trace direction:
|
|
89
|
+
*
|
|
90
|
+
* - `forward`: what the start uses (callees, instantiations, renders)
|
|
91
|
+
* - `reverse`: what uses the start (callers); the usual fit for caller
|
|
92
|
+
* questions
|
|
93
|
+
* - `impact`: reverse trace prioritizing public API and test nodes a change
|
|
94
|
+
* reaches; its test nodes are semantic usage edges, not a text search
|
|
58
95
|
*
|
|
59
96
|
* @default "forward"
|
|
60
97
|
*/
|
|
61
98
|
direction?: "forward" | "reverse" | "impact";
|
|
62
99
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
100
|
+
* Non-structural edge family to follow:
|
|
101
|
+
*
|
|
102
|
+
* - `execution`: runtime calls, instantiations, property access, JSX renders
|
|
103
|
+
* - `types`: type references and inheritance
|
|
104
|
+
* - `all`: the full graph
|
|
105
|
+
*
|
|
106
|
+
* Flow questions usually want `execution`, not `all`.
|
|
67
107
|
*
|
|
68
108
|
* @default "all"
|
|
69
109
|
*/
|
|
70
110
|
focus?: "all" | "execution" | "types";
|
|
71
111
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* Prefer the default for open traces. Raise only for path mode or when the
|
|
76
|
-
* previous trace named the missing next hop.
|
|
112
|
+
* Hops deep to follow (open forward/reverse cap at 8, impact at 4, path
|
|
113
|
+
* mode at 12). Raise it to follow a runtime chain to its end in one call.
|
|
77
114
|
*
|
|
78
|
-
* @default
|
|
115
|
+
* @default 3
|
|
79
116
|
*/
|
|
80
117
|
maxDepth?: number;
|
|
81
118
|
/**
|
|
82
|
-
* Cap on reached nodes
|
|
83
|
-
* Open forward/reverse traces are capped at 8 nodes, impact at 16 nodes.
|
|
119
|
+
* Cap on reached nodes (open forward/reverse cap at 32, impact at 16).
|
|
84
120
|
*
|
|
85
|
-
*
|
|
86
|
-
* requires it.
|
|
87
|
-
*
|
|
88
|
-
* @default 6
|
|
121
|
+
* @default 12
|
|
89
122
|
*/
|
|
90
123
|
maxNodes?: number;
|
|
91
124
|
/**
|
|
92
125
|
* Include dependency-boundary nodes from node_modules or bundled `.d.ts`
|
|
93
|
-
* libraries.
|
|
94
|
-
* asks about external type/API boundaries.
|
|
126
|
+
* libraries. Enable only for questions about external type/API boundaries.
|
|
95
127
|
*
|
|
96
128
|
* @default false
|
|
97
129
|
*/
|
|
@@ -107,17 +139,8 @@ export declare namespace ITtscGraphTrace {
|
|
|
107
139
|
kind: string;
|
|
108
140
|
/** Hops from the start (1 = direct). */
|
|
109
141
|
depth: number;
|
|
110
|
-
/**
|
|
111
|
-
* Source span for the expression that produced this hop. It is repository
|
|
112
|
-
* evidence for the hop and can be cited without opening the file.
|
|
113
|
-
*/
|
|
142
|
+
/** Source span that produced the hop: citable without opening the file. */
|
|
114
143
|
evidence?: ITtscGraphEvidence;
|
|
115
|
-
/**
|
|
116
|
-
* Stable access-path aliases derived from edge evidence. These preserve a
|
|
117
|
-
* resolved member's owner and the concrete property path used at the call
|
|
118
|
-
* site.
|
|
119
|
-
*/
|
|
120
|
-
aliases?: string[];
|
|
121
144
|
}
|
|
122
145
|
/** A node on the trace: the start, a reached node, or a candidate. */
|
|
123
146
|
interface INode {
|
|
@@ -6,5 +6,11 @@
|
|
|
6
6
|
* `extends`, `implements`, `overrides`, `renders`) are resolved by the checker
|
|
7
7
|
* — `renders` is a JSX component use. `decorates` carries a decorator fact and
|
|
8
8
|
* `tests` a test-to-subject relationship.
|
|
9
|
+
*
|
|
10
|
+
* `dispatches` is the runtime counterpart of `overrides`/`implements`: the
|
|
11
|
+
* checker resolves a call to the declaration it names, and where that
|
|
12
|
+
* declaration is abstract or an interface member, the code that runs is its
|
|
13
|
+
* implementation. It carries the implementation's declaration span, and a
|
|
14
|
+
* traversal that follows what executes emits it in place of the dead end.
|
|
9
15
|
*/
|
|
10
|
-
export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "decorates" | "renders" | "tests";
|
|
16
|
+
export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "dispatches" | "decorates" | "renders" | "tests";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./ITtscGraphApplication";
|
|
2
2
|
export * from "./ITtscGraphDecorator";
|
|
3
|
-
export * from "./ITtscGraphDiagnostic";
|
|
4
3
|
export * from "./ITtscGraphDump";
|
|
5
4
|
export * from "./ITtscGraphEdge";
|
|
6
5
|
export * from "./ITtscGraphEvidence";
|
|
@@ -12,6 +11,7 @@ export * from "./ITtscGraphOverview";
|
|
|
12
11
|
export * from "./ITtscGraphLookup";
|
|
13
12
|
export * from "./ITtscGraphNext";
|
|
14
13
|
export * from "./ITtscGraphTrace";
|
|
14
|
+
export * from "./ITtscGraphSpan";
|
|
15
15
|
export * from "./ITtscGraphTour";
|
|
16
16
|
export * from "./TtscGraphEdgeKind";
|
|
17
17
|
export * from "./TtscGraphNodeKind";
|
package/lib/structures/index.js
CHANGED
|
@@ -21,7 +21,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
__exportStar(require("./ITtscGraphApplication"), exports);
|
|
23
23
|
__exportStar(require("./ITtscGraphDecorator"), exports);
|
|
24
|
-
__exportStar(require("./ITtscGraphDiagnostic"), exports);
|
|
25
24
|
__exportStar(require("./ITtscGraphDump"), exports);
|
|
26
25
|
__exportStar(require("./ITtscGraphEdge"), exports);
|
|
27
26
|
__exportStar(require("./ITtscGraphEvidence"), exports);
|
|
@@ -33,6 +32,7 @@ __exportStar(require("./ITtscGraphOverview"), exports);
|
|
|
33
32
|
__exportStar(require("./ITtscGraphLookup"), exports);
|
|
34
33
|
__exportStar(require("./ITtscGraphNext"), exports);
|
|
35
34
|
__exportStar(require("./ITtscGraphTrace"), exports);
|
|
35
|
+
__exportStar(require("./ITtscGraphSpan"), exports);
|
|
36
36
|
__exportStar(require("./ITtscGraphTour"), exports);
|
|
37
37
|
__exportStar(require("./TtscGraphEdgeKind"), exports);
|
|
38
38
|
__exportStar(require("./TtscGraphNodeKind"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,0EAA0E;AAC1E,8EAA8E;AAC9E,gFAAgF;AAChF,6BAA6B;;;;;;;;;;;;;;;;AAE7B,0DAAwC;AACxC,wDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,0EAA0E;AAC1E,8EAA8E;AAC9E,gFAAgF;AAChF,6BAA6B;;;;;;;;;;;;;;;;AAE7B,0DAAwC;AACxC,wDAAsC;AACtC,mDAAiC;AACjC,mDAAiC;AACjC,uDAAqC;AACrC,qDAAmC;AACnC,sDAAoC;AACpC,0DAAwC;AACxC,mDAAiC;AACjC,uDAAqC;AACrC,qDAAmC;AACnC,mDAAiC;AACjC,oDAAkC;AAClC,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,0DAAwC"}
|
package/lib/view.js
CHANGED
|
@@ -50,7 +50,9 @@ function parseViewArgs(argv) {
|
|
|
50
50
|
*/
|
|
51
51
|
function runView(argv) {
|
|
52
52
|
const opts = parseViewArgs(argv);
|
|
53
|
-
|
|
53
|
+
// Anchor binary resolution at the project selected by `--cwd`, so `view` from
|
|
54
|
+
// an unrelated directory still finds the `ttsc` installed under the target.
|
|
55
|
+
const binary = (0, resolveGraphBinary_1.resolveGraphBinary)(process.env, opts.cwd);
|
|
54
56
|
if (binary === null) {
|
|
55
57
|
process.stderr.write("@ttsc/graph: could not resolve the ttscgraph binary. " +
|
|
56
58
|
"Install `ttsc` so its platform package is present, " +
|
package/lib/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAsD;AACtD,sDAAyB;AACzB,0DAA6B;AAC7B,0DAA6B;AAE7B,yDAAsD;AACtD,qCAAgD;AAChD,6DAA0D;AAU1D,SAAS,aAAa,CAAC,IAAuB;IAC5C,MAAM,IAAI,GAAgB;QACxB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,QAAQ,EAAE,eAAe;QACzB,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACrB,IAAI,GAAG,KAAK,OAAO;YAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;aACjD,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,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;IAAC,MAAM,CAAC;QACP,kDAAkD;IACpD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Checker-resolved architecture graph over MCP for coding agents, backed by ttsc's in-process TypeScript-Go compiler.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
19
|
-
"@typia/mcp": "
|
|
20
|
-
"typia": "
|
|
19
|
+
"@typia/mcp": "13.1.0",
|
|
20
|
+
"typia": "13.1.0"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"ttsc",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"three": "^0.184.0",
|
|
40
40
|
"three-forcegraph": "^1.43.4",
|
|
41
41
|
"typescript": "^7.0.2",
|
|
42
|
-
"ttsc": "0.
|
|
42
|
+
"ttsc": "0.19.0"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { TtscGraphMemory } from "./model/TtscGraphMemory";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
RESULT_AUDIT,
|
|
4
|
+
RESULT_AUDIT_ESCAPE,
|
|
5
|
+
RESULT_AUDIT_SELECTION,
|
|
6
|
+
} from "./server/resultAudit";
|
|
7
|
+
import { resultNext } from "./server/resultNext";
|
|
3
8
|
import { runDetails } from "./server/runDetails";
|
|
4
9
|
import { runEntrypoints } from "./server/runEntrypoints";
|
|
5
10
|
import { runLookup } from "./server/runLookup";
|
|
@@ -9,7 +14,9 @@ import { runTrace } from "./server/runTrace";
|
|
|
9
14
|
import { ITtscGraphApplication } from "./structures/ITtscGraphApplication";
|
|
10
15
|
import { ITtscGraphEscape } from "./structures/ITtscGraphEscape";
|
|
11
16
|
|
|
12
|
-
export type TtscGraphSource =
|
|
17
|
+
export type TtscGraphSource =
|
|
18
|
+
| TtscGraphMemory
|
|
19
|
+
| (() => TtscGraphMemory | Promise<TtscGraphMemory>);
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* The MCP tool surface as a plain class over the resident
|
|
@@ -22,77 +29,105 @@ export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory);
|
|
|
22
29
|
* The method delegates to the pure graph functions in `./server`, which are
|
|
23
30
|
* unit-testable without a transport; this class only binds them to the graph.
|
|
24
31
|
*
|
|
25
|
-
* Every method answers from the resident graph
|
|
32
|
+
* Every method answers from the current resident graph. The source may refresh
|
|
33
|
+
* that graph before the operation when project files changed. Output is kept
|
|
26
34
|
* compact and bounded so a model can read structure without a file read, which
|
|
27
35
|
* is the token win the redesign exists for.
|
|
28
36
|
*/
|
|
29
37
|
export class TtscGraphApplication implements ITtscGraphApplication {
|
|
30
|
-
private readonly graph: () => TtscGraphMemory
|
|
38
|
+
private readonly graph: () => TtscGraphMemory | Promise<TtscGraphMemory>;
|
|
31
39
|
|
|
32
40
|
public constructor(source: TtscGraphSource) {
|
|
33
41
|
this.graph = typeof source === "function" ? source : () => source;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
public inspect_typescript_graph(
|
|
44
|
+
public async inspect_typescript_graph(
|
|
37
45
|
props: ITtscGraphApplication.IProps,
|
|
38
|
-
): ITtscGraphApplication.
|
|
46
|
+
): Promise<ITtscGraphApplication.IOutput> {
|
|
39
47
|
if (props.request.type === "escape") {
|
|
40
48
|
const result = this.escape(props.request.reason);
|
|
41
49
|
if (props.request.nextStep !== undefined) {
|
|
42
50
|
result.nextStep = props.request.nextStep;
|
|
43
51
|
}
|
|
44
52
|
return {
|
|
53
|
+
audit: RESULT_AUDIT_ESCAPE,
|
|
54
|
+
next: resultNext(
|
|
55
|
+
"outside",
|
|
56
|
+
"The caller chose to leave the graph, so this call carries no graph facts.",
|
|
57
|
+
),
|
|
45
58
|
result,
|
|
46
59
|
};
|
|
47
60
|
}
|
|
61
|
+
const graph = await this.graph();
|
|
48
62
|
switch (props.request.type) {
|
|
49
|
-
case "entrypoints":
|
|
63
|
+
case "entrypoints": {
|
|
64
|
+
// A ranked shortlist matched against the question: its facts are
|
|
65
|
+
// compiler-verified, but its selection is heuristic, so it carries the
|
|
66
|
+
// selection audit rather than the exact-structure one.
|
|
67
|
+
const r = runEntrypoints(graph, props.request);
|
|
50
68
|
return {
|
|
51
|
-
|
|
69
|
+
audit: RESULT_AUDIT_SELECTION,
|
|
70
|
+
next: r.next,
|
|
71
|
+
result: r.result,
|
|
52
72
|
};
|
|
53
|
-
|
|
73
|
+
}
|
|
74
|
+
case "lookup": {
|
|
75
|
+
// Natural-query ranker (see `runLookup`): scored, ranked, per-file
|
|
76
|
+
// capped, and limited, so the selection is heuristic.
|
|
77
|
+
const r = runLookup(graph, props.request);
|
|
54
78
|
return {
|
|
55
|
-
|
|
79
|
+
audit: RESULT_AUDIT_SELECTION,
|
|
80
|
+
next: r.next,
|
|
81
|
+
result: r.result,
|
|
56
82
|
};
|
|
57
|
-
|
|
83
|
+
}
|
|
84
|
+
case "trace": {
|
|
85
|
+
const r = runTrace(graph, props.request);
|
|
58
86
|
return {
|
|
59
|
-
|
|
87
|
+
audit: RESULT_AUDIT,
|
|
88
|
+
next: r.next,
|
|
89
|
+
result: r.result,
|
|
60
90
|
};
|
|
61
|
-
|
|
91
|
+
}
|
|
92
|
+
case "details": {
|
|
93
|
+
const r = runDetails(graph, props.request);
|
|
62
94
|
return {
|
|
63
|
-
|
|
95
|
+
audit: RESULT_AUDIT,
|
|
96
|
+
next: r.next,
|
|
97
|
+
result: r.result,
|
|
64
98
|
};
|
|
65
|
-
|
|
99
|
+
}
|
|
100
|
+
case "overview": {
|
|
101
|
+
const r = runOverview(graph, props.request);
|
|
66
102
|
return {
|
|
67
|
-
|
|
103
|
+
audit: RESULT_AUDIT,
|
|
104
|
+
next: r.next,
|
|
105
|
+
result: r.result,
|
|
68
106
|
};
|
|
69
|
-
|
|
107
|
+
}
|
|
108
|
+
case "tour": {
|
|
109
|
+
// The tour ranks against the question, and the question is `props`
|
|
110
|
+
// — the caller wrote it once, at the top, in the user's words. It
|
|
111
|
+
// ranks seeds, walks bounded flows, and slices to a limit, so its
|
|
112
|
+
// selection is heuristic.
|
|
113
|
+
const r = runTour(graph, props.request, props.question);
|
|
70
114
|
return {
|
|
71
|
-
|
|
115
|
+
audit: RESULT_AUDIT_SELECTION,
|
|
116
|
+
next: r.next,
|
|
117
|
+
result: r.result,
|
|
72
118
|
};
|
|
119
|
+
}
|
|
73
120
|
default:
|
|
74
121
|
props.request satisfies never;
|
|
75
122
|
throw new Error("Unknown graph request type");
|
|
76
123
|
}
|
|
77
124
|
}
|
|
78
125
|
|
|
79
|
-
private escape(
|
|
80
|
-
reason: string,
|
|
81
|
-
nextStep?: string,
|
|
82
|
-
action: "answer" | "outside" | "clarify" = "outside",
|
|
83
|
-
): ITtscGraphEscape {
|
|
126
|
+
private escape(reason: string, nextStep?: string): ITtscGraphEscape {
|
|
84
127
|
return {
|
|
85
128
|
type: "escape",
|
|
86
129
|
skipped: true,
|
|
87
130
|
reason,
|
|
88
|
-
next: resultNext(
|
|
89
|
-
action,
|
|
90
|
-
nextStep ??
|
|
91
|
-
"Graph evidence is exhausted or not the next evidence source.",
|
|
92
|
-
),
|
|
93
|
-
guide: resultGuide(
|
|
94
|
-
"Finish from existing graph evidence, state the graph gap, or ask for clarification.",
|
|
95
|
-
),
|
|
96
131
|
...(nextStep !== undefined ? { nextStep } : {}),
|
|
97
132
|
};
|
|
98
133
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,21 @@ import { resolveGraphBinary } from "./resolveGraphBinary";
|
|
|
6
6
|
import { startServer } from "./server/startServer";
|
|
7
7
|
import { runView } from "./view";
|
|
8
8
|
|
|
9
|
+
/** What a graph result says about where its facts came from. */
|
|
10
|
+
export {
|
|
11
|
+
RESULT_AUDIT,
|
|
12
|
+
RESULT_AUDIT_ESCAPE,
|
|
13
|
+
RESULT_AUDIT_SELECTION,
|
|
14
|
+
} from "./server/resultAudit";
|
|
15
|
+
|
|
16
|
+
// Programmatic entry points. Each resolves its native binary from the project
|
|
17
|
+
// `cwd` it is given (see `resolveGraphBinary`), so a caller that graphs a
|
|
18
|
+
// project other than its own process directory names it once and the binary is
|
|
19
|
+
// found under that project's installed `ttsc`.
|
|
20
|
+
export { resolveGraphBinary } from "./resolveGraphBinary";
|
|
21
|
+
export { loadGraph } from "./model/loadGraph";
|
|
22
|
+
export { TtscGraphSession } from "./model/TtscGraphSession";
|
|
23
|
+
|
|
9
24
|
// The server version reported in the MCP handshake; read from this package.
|
|
10
25
|
const VERSION: string = (require("../package.json") as { version: string })
|
|
11
26
|
.version;
|
|
@@ -38,10 +53,10 @@ function parseProjectArgs(argv: readonly string[]): {
|
|
|
38
53
|
* - `view`: JS-orchestrated 3D viewer (dump -> reduce -> serve -> open).
|
|
39
54
|
* - `dump`: pass through to the native `ttscgraph dump`, which prints the whole
|
|
40
55
|
* graph as JSON for piping or the viewer.
|
|
41
|
-
* - Default: serve the MCP graph over stdio. The TypeScript server
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
56
|
+
* - Default: serve the MCP graph over stdio. The TypeScript server keeps a native
|
|
57
|
+
* incremental compiler session resident, checks the disk snapshot before each
|
|
58
|
+
* graph operation, and reuses the in-memory graph when unchanged; the agent's
|
|
59
|
+
* MCP client speaks JSON-RPC over this process's stdin/stdout.
|
|
45
60
|
*/
|
|
46
61
|
export function runGraph(
|
|
47
62
|
argv: readonly string[] = process.argv.slice(2),
|
|
@@ -65,7 +80,10 @@ export function runGraph(
|
|
|
65
80
|
* on this process's stdout. Returns the child's exit code.
|
|
66
81
|
*/
|
|
67
82
|
function runDump(argv: readonly string[]): number {
|
|
68
|
-
|
|
83
|
+
// Resolve the native binary from the target project the caller named with
|
|
84
|
+
// `--cwd`, not from wherever the launcher process happened to start.
|
|
85
|
+
const { cwd } = parseProjectArgs(argv);
|
|
86
|
+
const binary = resolveGraphBinary(process.env, cwd);
|
|
69
87
|
if (binary === null) {
|
|
70
88
|
process.stderr.write(
|
|
71
89
|
"@ttsc/graph: could not resolve the ttscgraph binary. " +
|