@ttsc/graph 0.16.7 → 0.16.9
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 +41 -43
- package/lib/TtscGraphApplication.js +5 -3
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/model/loadGraph.js +74 -90
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/reduce.js +34 -3
- package/lib/reduce.js.map +1 -1
- package/lib/server/createServer.js +199 -189
- package/lib/server/createServer.js.map +1 -1
- package/package.json +4 -8
- package/src/TtscGraphApplication.ts +5 -3
- package/src/reduce.ts +37 -5
- package/src/server/createServer.ts +18 -88
- package/src/structures/ITtscGraphApplication.ts +104 -6
- package/lib/server/instructions.js +0 -92
- package/lib/server/instructions.js.map +0 -1
- package/src/server/instructions.ts +0 -88
package/README.md
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
# `@ttsc/graph`
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
[](https://github.com/samchon/ttsc/blob/master/LICENSE) [](https://www.npmjs.com/package/@ttsc/graph) [](https://www.npmjs.com/package/@ttsc/graph) [](https://github.com/samchon/ttsc/actions?query=workflow%3Atest) [](https://ttsc.dev/docs/graph) [](https://discord.gg/E94XhzrUCZ)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`@ttsc/graph` gives your coding agent a **graph of your TypeScript codebase** over MCP: what calls what, what depends on what, where each piece lives.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
It is drawn by the real TypeScript compiler, so it is exact, and every claim is anchored to a file and line you can open.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The agent answers structural questions from the graph instead of crawling file by file, which cuts its tokens by roughly 10x on open-ended "how does this work?" questions.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
You can also browse the whole map. This is TypeORM in 3D, colored by kind ([live viewer](https://ttsc.dev/docs/graph/viewer)):
|
|
16
|
-
|
|
17
|
-
[](https://ttsc.dev/docs/graph/viewer)
|
|
13
|
+
For why I built it, how it works in depth, and how it compares to `codegraph`, `codebase-memory-mcp`, and `serena`, read the launch post: https://ttsc.dev/blog/i-made-ts-compiler-graph-mcp
|
|
18
14
|
|
|
19
15
|
## Setup
|
|
20
16
|
|
|
21
|
-
### Install
|
|
22
|
-
|
|
23
17
|
```bash
|
|
24
18
|
npm install -D ttsc @ttsc/graph typescript@rc
|
|
25
19
|
```
|
|
26
20
|
|
|
27
|
-
`@ttsc/graph` reads the
|
|
28
|
-
|
|
29
|
-
### Connect your agent
|
|
21
|
+
`@ttsc/graph` reads the graph from the program `ttsc` type-checked, so install the two together.
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
`ttsc` runs on the TypeScript-Go (TypeScript v7) runtime, which is still a release candidate, so the install pins `typescript@rc`. It does not run on stable TypeScript v6.x yet.
|
|
32
24
|
|
|
33
|
-
For Claude Code, that is a `.mcp.json` in your project root:
|
|
25
|
+
Add the server to your agent's MCP config, once. For Claude Code, that is a `.mcp.json` in your project root:
|
|
34
26
|
|
|
35
27
|
```json
|
|
36
28
|
{
|
|
@@ -43,37 +35,49 @@ For Claude Code, that is a `.mcp.json` in your project root:
|
|
|
43
35
|
}
|
|
44
36
|
```
|
|
45
37
|
|
|
46
|
-
Start your agent from your project root so the server finds your `tsconfig.json`. The agent queries the
|
|
38
|
+
Start your agent from your project root so the server finds your `tsconfig.json`. The agent queries the graph on its own; you never call it by hand.
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
The example says Claude Code, but any MCP-capable agent works (Codex, Cursor, and others).
|
|
49
41
|
|
|
50
|
-
|
|
42
|
+
## How it works
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
The whole MCP surface is one tool, `inspect_typescript_graph`. You ask in plain language, and a short required chain of thought inside the tool (`question`, `draft`, `review`) plans the smallest query and picks one operation.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
- **An index, not source bodies.** It returns names, edges, signatures, and spans, never code, so the response stays flat as the repository grows.
|
|
49
|
+
- **Built on the real compiler.** It reads the program `ttsc` type-checked, so `tsconfig` aliases, pnpm monorepos, symlinks, and re-exports resolve exactly, where a text parser can only guess.
|
|
50
|
+
- **It does not force itself.** It states when the graph is the right source and offers a first-class `escape` for everything else.
|
|
51
|
+
- **Errors and lint too.** `tsc` compile errors and `@ttsc/lint` and plugin (typia, nestia) findings ride the same graph, so "what is broken here?" answers from one index.
|
|
52
|
+
|
|
53
|
+
The operations (`tour`, `entrypoints`, `lookup`, `trace`, `details`, `overview`, `escape`) and the full request and result contract are in the Design guide: https://ttsc.dev/docs/graph/design
|
|
55
54
|
|
|
56
55
|
## Benchmark
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+

|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
xychart-beta
|
|
62
|
-
title "Common prompt median token use"
|
|
63
|
-
x-axis ["baseline", "@ttsc/graph", "codegraph", "codebase-memory-mcp"]
|
|
64
|
-
y-axis "Tokens (k)" 0 --> 1400
|
|
65
|
-
bar [781, 41, 617, 1302]
|
|
66
|
-
```
|
|
59
|
+
Across eight real repositories, `@ttsc/graph` holds a flat, low median token cost while the alternatives swing with repository size.
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
The full benchmark has the interactive charts, every model, and the method: https://ttsc.dev/docs/benchmark/graph
|
|
62
|
+
|
|
63
|
+
## Browse it in 3D
|
|
64
|
+
|
|
65
|
+
Run this in your own project to open the graph in your browser, served from a local port:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx @ttsc/graph view
|
|
74
69
|
```
|
|
75
70
|
|
|
76
|
-
|
|
71
|
+
This is TypeORM in 3D, colored by kind ([live viewer](https://ttsc.dev/docs/graph/viewer)):
|
|
72
|
+
|
|
73
|
+
[](https://ttsc.dev/docs/graph/viewer)
|
|
74
|
+
|
|
75
|
+
## Learn more
|
|
76
|
+
|
|
77
|
+
- [Launch post](https://ttsc.dev/blog/i-made-ts-compiler-graph-mcp): why I built it, and how it compares to `codegraph`, `codebase-memory-mcp`, and `serena`.
|
|
78
|
+
- [Design](https://ttsc.dev/docs/graph/design): the one tool, its request and result branches, and the node and edge kinds.
|
|
79
|
+
- [Comparison](https://ttsc.dev/docs/graph/compare): the head-to-head with other graph and language-server MCP tools.
|
|
80
|
+
- [Benchmark](https://ttsc.dev/docs/benchmark/graph): the interactive charts, every model, and the method.
|
|
77
81
|
|
|
78
82
|
## Sponsors
|
|
79
83
|
|
|
@@ -82,9 +86,3 @@ See the [full benchmark page](https://ttsc.dev/docs/benchmark/graph) for the raw
|
|
|
82
86
|
Thanks for your support.
|
|
83
87
|
|
|
84
88
|
Your [donation](https://github.com/sponsors/samchon) encourages `ttsc` development.
|
|
85
|
-
|
|
86
|
-
## References
|
|
87
|
-
|
|
88
|
-
`@ttsc/graph` is inspired by [codegraph](https://github.com/colbymchenry/codegraph), which first put a code graph in front of an agent over MCP. The [benchmark](https://ttsc.dev/docs/benchmark/graph) here is a faithful port of codegraph's.
|
|
89
|
-
|
|
90
|
-
The difference is where the map comes from. codegraph parses the shape of your code and infers how the pieces connect, while `@ttsc/graph` asks the real TypeScript compiler, which has already resolved every import and reference, so the map is exact rather than inferred.
|
|
@@ -12,10 +12,11 @@ const runTrace_1 = require("./server/runTrace");
|
|
|
12
12
|
* The MCP tool surface as a plain class over the resident
|
|
13
13
|
* {@link TtscGraphMemory}.
|
|
14
14
|
*
|
|
15
|
-
* Its public method is the MCP tool: `typia.llm.
|
|
15
|
+
* Its public method is the MCP tool: `typia.llm.application` reflects
|
|
16
16
|
* {@link ITtscGraphApplication} to generate the tool's JSON schema and argument
|
|
17
|
-
* validator from the signature and JSDoc, with no hand-written schema
|
|
18
|
-
*
|
|
17
|
+
* validator from the signature and JSDoc, with no hand-written schema, and
|
|
18
|
+
* `@typia/mcp`'s `createMcpServer` registers it (see `./server/createServer`).
|
|
19
|
+
* The method delegates to the pure graph functions in `./server`, which are
|
|
19
20
|
* unit-testable without a transport; this class only binds them to the graph.
|
|
20
21
|
*
|
|
21
22
|
* Every method answers from the resident graph; none recompiles. Output is kept
|
|
@@ -63,6 +64,7 @@ class TtscGraphApplication {
|
|
|
63
64
|
result: (0, runTour_1.runTour)(this.graph(), props.request),
|
|
64
65
|
};
|
|
65
66
|
default:
|
|
67
|
+
props.request;
|
|
66
68
|
throw new Error("Unknown graph request type");
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TtscGraphApplication.js","sourceRoot":"","sources":["../src/TtscGraphApplication.ts"],"names":[],"mappings":";;;AACA,sDAA+D;AAC/D,oDAAiD;AACjD,4DAAyD;AACzD,kDAA+C;AAC/C,sDAAmD;AACnD,8CAA2C;AAC3C,gDAA6C;AAM7C
|
|
1
|
+
{"version":3,"file":"TtscGraphApplication.js","sourceRoot":"","sources":["../src/TtscGraphApplication.ts"],"names":[],"mappings":";;;AACA,sDAA+D;AAC/D,oDAAiD;AACjD,4DAAyD;AACzD,kDAA+C;AAC/C,sDAAmD;AACnD,8CAA2C;AAC3C,gDAA6C;AAM7C;;;;;;;;;;;;;;GAcG;AACH;IACmB,KAAK,CAAwB;IAE9C,YAAmB,MAAuB;QACxC,IAAI,CAAC,KAAK,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACpE,CAAC;IAEM,wBAAwB,CAC7B,KAAmC;QAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC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YACb,MAAM;YACN,IAAI,EAAE,IAAA,wBAAU,EACd,MAAM,EACN,QAAQ;gBACN,8DAA8D,CACjE;YACD,KAAK,EAAE,IAAA,yBAAW,EAChB,qFAAqF,CACtF;YACD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;CACF"}
|
package/lib/model/loadGraph.js
CHANGED
|
@@ -89,12 +89,41 @@ function parseDump(json) {
|
|
|
89
89
|
throw new Error(`@ttsc/graph: dump output is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
90
90
|
}
|
|
91
91
|
return (() => {
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
92
|
+
const _iv0 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
|
|
93
|
+
const _ip0 = input => "string" === typeof input["name"];
|
|
94
|
+
const _ip1 = input => "string" === typeof input["file"];
|
|
95
|
+
const _iv1 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
|
|
96
|
+
const _ip2 = input => undefined === input["evidence"] || "object" === typeof input["evidence"] && null !== input["evidence"] && _io4(input["evidence"]);
|
|
97
|
+
const _iv2 = new Set(["accesses", "calls", "contains", "decorates", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
|
|
98
|
+
const _av0 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
|
|
99
|
+
const _ae0 = "(\"class\" | \"enum\" | \"external_symbol\" | \"file\" | \"function\" | \"interface\" | \"method\" | \"module\" | \"namespace\" | \"package\" | \"parameter\" | \"property\" | \"type\" | \"variable\")";
|
|
100
|
+
const _ap0 = (input, _path, _exceptionable = true) => "string" === typeof input["name"] || _a._assertGuard(_exceptionable, {
|
|
101
|
+
method: "typia.assert",
|
|
102
|
+
path: _path + ".name",
|
|
103
|
+
expected: "string",
|
|
104
|
+
value: input["name"]
|
|
105
|
+
}, _errorFactory);
|
|
106
|
+
const _ap1 = (input, _path, _exceptionable = true) => "string" === typeof input["file"] || _a._assertGuard(_exceptionable, {
|
|
107
|
+
method: "typia.assert",
|
|
108
|
+
path: _path + ".file",
|
|
109
|
+
expected: "string",
|
|
110
|
+
value: input["file"]
|
|
111
|
+
}, _errorFactory);
|
|
112
|
+
const _av1 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
|
|
113
|
+
const _ae1 = "(\"abstract\" | \"async\" | \"const\" | \"declare\" | \"default\" | \"export\" | \"optional\" | \"private\" | \"protected\" | \"public\" | \"readonly\" | \"static\")";
|
|
114
|
+
const _ap2 = (input, _path, _exceptionable = true) => undefined === input["evidence"] || ("object" === typeof input["evidence"] && null !== input["evidence"] || _a._assertGuard(_exceptionable, {
|
|
115
|
+
method: "typia.assert",
|
|
116
|
+
path: _path + ".evidence",
|
|
117
|
+
expected: "(ITtscGraphEvidence | undefined)",
|
|
118
|
+
value: input["evidence"]
|
|
119
|
+
}, _errorFactory)) && _ao4(input["evidence"], _path + ".evidence", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
120
|
+
method: "typia.assert",
|
|
121
|
+
path: _path + ".evidence",
|
|
122
|
+
expected: "(ITtscGraphEvidence | undefined)",
|
|
123
|
+
value: input["evidence"]
|
|
124
|
+
}, _errorFactory);
|
|
125
|
+
const _av2 = new Set(["accesses", "calls", "contains", "decorates", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
|
|
126
|
+
const _ae2 = "(\"accesses\" | \"calls\" | \"contains\" | \"decorates\" | \"exports\" | \"extends\" | \"implements\" | \"imports\" | \"instantiates\" | \"overrides\" | \"renders\" | \"tests\" | \"type_ref\")";
|
|
98
127
|
const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.project || _a._assertGuard(_exceptionable, {
|
|
99
128
|
method: "typia.assert",
|
|
100
129
|
path: _path + ".project",
|
|
@@ -110,14 +139,14 @@ function parseDump(json) {
|
|
|
110
139
|
path: _path + ".nodes",
|
|
111
140
|
expected: "Array<ITtscGraphNode>",
|
|
112
141
|
value: input.nodes
|
|
113
|
-
}, _errorFactory)) && input.nodes.every((elem,
|
|
142
|
+
}, _errorFactory)) && input.nodes.every((elem, _index7) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
|
|
114
143
|
method: "typia.assert",
|
|
115
|
-
path: _path + ".nodes[" +
|
|
144
|
+
path: _path + ".nodes[" + _index7 + "]",
|
|
116
145
|
expected: "ITtscGraphNode",
|
|
117
146
|
value: elem
|
|
118
|
-
}, _errorFactory)) && _ao1(elem, _path + ".nodes[" +
|
|
147
|
+
}, _errorFactory)) && _ao1(elem, _path + ".nodes[" + _index7 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
119
148
|
method: "typia.assert",
|
|
120
|
-
path: _path + ".nodes[" +
|
|
149
|
+
path: _path + ".nodes[" + _index7 + "]",
|
|
121
150
|
expected: "ITtscGraphNode",
|
|
122
151
|
value: elem
|
|
123
152
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
@@ -130,14 +159,14 @@ function parseDump(json) {
|
|
|
130
159
|
path: _path + ".edges",
|
|
131
160
|
expected: "Array<ITtscGraphEdge>",
|
|
132
161
|
value: input.edges
|
|
133
|
-
}, _errorFactory)) && input.edges.every((elem,
|
|
162
|
+
}, _errorFactory)) && input.edges.every((elem, _index8) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
|
|
134
163
|
method: "typia.assert",
|
|
135
|
-
path: _path + ".edges[" +
|
|
164
|
+
path: _path + ".edges[" + _index8 + "]",
|
|
136
165
|
expected: "ITtscGraphEdge",
|
|
137
166
|
value: elem
|
|
138
|
-
}, _errorFactory)) && _ao5(elem, _path + ".edges[" +
|
|
167
|
+
}, _errorFactory)) && _ao5(elem, _path + ".edges[" + _index8 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
139
168
|
method: "typia.assert",
|
|
140
|
-
path: _path + ".edges[" +
|
|
169
|
+
path: _path + ".edges[" + _index8 + "]",
|
|
141
170
|
expected: "ITtscGraphEdge",
|
|
142
171
|
value: elem
|
|
143
172
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
@@ -150,14 +179,14 @@ function parseDump(json) {
|
|
|
150
179
|
path: _path + ".diagnostics",
|
|
151
180
|
expected: "(Array<ITtscGraphDiagnostic> | undefined)",
|
|
152
181
|
value: input.diagnostics
|
|
153
|
-
}, _errorFactory)) && input.diagnostics.every((elem,
|
|
182
|
+
}, _errorFactory)) && input.diagnostics.every((elem, _index9) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
|
|
154
183
|
method: "typia.assert",
|
|
155
|
-
path: _path + ".diagnostics[" +
|
|
184
|
+
path: _path + ".diagnostics[" + _index9 + "]",
|
|
156
185
|
expected: "ITtscGraphDiagnostic",
|
|
157
186
|
value: elem
|
|
158
|
-
}, _errorFactory)) && _ao6(elem, _path + ".diagnostics[" +
|
|
187
|
+
}, _errorFactory)) && _ao6(elem, _path + ".diagnostics[" + _index9 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
159
188
|
method: "typia.assert",
|
|
160
|
-
path: _path + ".diagnostics[" +
|
|
189
|
+
path: _path + ".diagnostics[" + _index9 + "]",
|
|
161
190
|
expected: "ITtscGraphDiagnostic",
|
|
162
191
|
value: elem
|
|
163
192
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
@@ -171,27 +200,17 @@ function parseDump(json) {
|
|
|
171
200
|
path: _path + ".id",
|
|
172
201
|
expected: "string",
|
|
173
202
|
value: input.id
|
|
174
|
-
}, _errorFactory)) && (true ===
|
|
203
|
+
}, _errorFactory)) && (true === _av0.has(input.kind) || _a._assertGuard(_exceptionable, {
|
|
175
204
|
method: "typia.assert",
|
|
176
205
|
path: _path + ".kind",
|
|
177
|
-
expected:
|
|
206
|
+
expected: _ae0,
|
|
178
207
|
value: input.kind
|
|
179
|
-
}, _errorFactory)) && ("string" === typeof input.
|
|
180
|
-
method: "typia.assert",
|
|
181
|
-
path: _path + ".name",
|
|
182
|
-
expected: "string",
|
|
183
|
-
value: input.name
|
|
184
|
-
}, _errorFactory)) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName || _a._assertGuard(_exceptionable, {
|
|
208
|
+
}, _errorFactory)) && _ap0(input, _path, true && _exceptionable) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName || _a._assertGuard(_exceptionable, {
|
|
185
209
|
method: "typia.assert",
|
|
186
210
|
path: _path + ".qualifiedName",
|
|
187
211
|
expected: "(string | undefined)",
|
|
188
212
|
value: input.qualifiedName
|
|
189
|
-
}, _errorFactory)) && ("
|
|
190
|
-
method: "typia.assert",
|
|
191
|
-
path: _path + ".file",
|
|
192
|
-
expected: "string",
|
|
193
|
-
value: input.file
|
|
194
|
-
}, _errorFactory)) && ("boolean" === typeof input.external || _a._assertGuard(_exceptionable, {
|
|
213
|
+
}, _errorFactory)) && _ap1(input, _path, true && _exceptionable) && ("boolean" === typeof input.external || _a._assertGuard(_exceptionable, {
|
|
195
214
|
method: "typia.assert",
|
|
196
215
|
path: _path + ".external",
|
|
197
216
|
expected: "boolean",
|
|
@@ -211,10 +230,10 @@ function parseDump(json) {
|
|
|
211
230
|
path: _path + ".modifiers",
|
|
212
231
|
expected: "(Array<TtscGraphNodeModifier> | undefined)",
|
|
213
232
|
value: input.modifiers
|
|
214
|
-
}, _errorFactory)) && input.modifiers.every((elem,
|
|
233
|
+
}, _errorFactory)) && input.modifiers.every((elem, _index10) => true === _av1.has(elem) || _a._assertGuard(_exceptionable, {
|
|
215
234
|
method: "typia.assert",
|
|
216
|
-
path: _path + ".modifiers[" +
|
|
217
|
-
expected:
|
|
235
|
+
path: _path + ".modifiers[" + _index10 + "]",
|
|
236
|
+
expected: _ae1,
|
|
218
237
|
value: elem
|
|
219
238
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
220
239
|
method: "typia.assert",
|
|
@@ -226,14 +245,14 @@ function parseDump(json) {
|
|
|
226
245
|
path: _path + ".decorators",
|
|
227
246
|
expected: "(Array<ITtscGraphDecorator> | undefined)",
|
|
228
247
|
value: input.decorators
|
|
229
|
-
}, _errorFactory)) && input.decorators.every((elem,
|
|
248
|
+
}, _errorFactory)) && input.decorators.every((elem, _index11) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
|
|
230
249
|
method: "typia.assert",
|
|
231
|
-
path: _path + ".decorators[" +
|
|
250
|
+
path: _path + ".decorators[" + _index11 + "]",
|
|
232
251
|
expected: "ITtscGraphDecorator",
|
|
233
252
|
value: elem
|
|
234
|
-
}, _errorFactory)) && _ao2(elem, _path + ".decorators[" +
|
|
253
|
+
}, _errorFactory)) && _ao2(elem, _path + ".decorators[" + _index11 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
235
254
|
method: "typia.assert",
|
|
236
|
-
path: _path + ".decorators[" +
|
|
255
|
+
path: _path + ".decorators[" + _index11 + "]",
|
|
237
256
|
expected: "ITtscGraphDecorator",
|
|
238
257
|
value: elem
|
|
239
258
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
@@ -241,17 +260,7 @@ function parseDump(json) {
|
|
|
241
260
|
path: _path + ".decorators",
|
|
242
261
|
expected: "(Array<ITtscGraphDecorator> | undefined)",
|
|
243
262
|
value: input.decorators
|
|
244
|
-
}, _errorFactory)) && (undefined === input.
|
|
245
|
-
method: "typia.assert",
|
|
246
|
-
path: _path + ".evidence",
|
|
247
|
-
expected: "(ITtscGraphEvidence | undefined)",
|
|
248
|
-
value: input.evidence
|
|
249
|
-
}, _errorFactory)) && _ao4(input.evidence, _path + ".evidence", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
250
|
-
method: "typia.assert",
|
|
251
|
-
path: _path + ".evidence",
|
|
252
|
-
expected: "(ITtscGraphEvidence | undefined)",
|
|
253
|
-
value: input.evidence
|
|
254
|
-
}, _errorFactory)) && (undefined === input.implementation || ("object" === typeof input.implementation && null !== input.implementation || _a._assertGuard(_exceptionable, {
|
|
263
|
+
}, _errorFactory)) && _ap2(input, _path, true && _exceptionable) && (undefined === input.implementation || ("object" === typeof input.implementation && null !== input.implementation || _a._assertGuard(_exceptionable, {
|
|
255
264
|
method: "typia.assert",
|
|
256
265
|
path: _path + ".implementation",
|
|
257
266
|
expected: "(ITtscGraphEvidence | undefined)",
|
|
@@ -262,24 +271,19 @@ function parseDump(json) {
|
|
|
262
271
|
expected: "(ITtscGraphEvidence | undefined)",
|
|
263
272
|
value: input.implementation
|
|
264
273
|
}, _errorFactory));
|
|
265
|
-
const _ao2 = (input, _path, _exceptionable = true) => (
|
|
266
|
-
method: "typia.assert",
|
|
267
|
-
path: _path + ".name",
|
|
268
|
-
expected: "string",
|
|
269
|
-
value: input.name
|
|
270
|
-
}, _errorFactory)) && ((Array.isArray(input.arguments) || _a._assertGuard(_exceptionable, {
|
|
274
|
+
const _ao2 = (input, _path, _exceptionable = true) => _ap0(input, _path, true && _exceptionable) && ((Array.isArray(input.arguments) || _a._assertGuard(_exceptionable, {
|
|
271
275
|
method: "typia.assert",
|
|
272
276
|
path: _path + ".arguments",
|
|
273
277
|
expected: "Array<ITtscGraphDecorator.IArgument>",
|
|
274
278
|
value: input.arguments
|
|
275
|
-
}, _errorFactory)) && input.arguments.every((elem,
|
|
279
|
+
}, _errorFactory)) && input.arguments.every((elem, _index12) => ("object" === typeof elem && null !== elem && false === Array.isArray(elem) || _a._assertGuard(_exceptionable, {
|
|
276
280
|
method: "typia.assert",
|
|
277
|
-
path: _path + ".arguments[" +
|
|
281
|
+
path: _path + ".arguments[" + _index12 + "]",
|
|
278
282
|
expected: "ITtscGraphDecorator.IArgument",
|
|
279
283
|
value: elem
|
|
280
|
-
}, _errorFactory)) && _ao3(elem, _path + ".arguments[" +
|
|
284
|
+
}, _errorFactory)) && _ao3(elem, _path + ".arguments[" + _index12 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
281
285
|
method: "typia.assert",
|
|
282
|
-
path: _path + ".arguments[" +
|
|
286
|
+
path: _path + ".arguments[" + _index12 + "]",
|
|
283
287
|
expected: "ITtscGraphDecorator.IArgument",
|
|
284
288
|
value: elem
|
|
285
289
|
}, _errorFactory)) || _a._assertGuard(_exceptionable, {
|
|
@@ -294,12 +298,7 @@ function parseDump(json) {
|
|
|
294
298
|
expected: "(boolean | number | string | undefined)",
|
|
295
299
|
value: input.literal
|
|
296
300
|
}, _errorFactory);
|
|
297
|
-
const _ao4 = (input, _path, _exceptionable = true) => ("
|
|
298
|
-
method: "typia.assert",
|
|
299
|
-
path: _path + ".file",
|
|
300
|
-
expected: "string",
|
|
301
|
-
value: input.file
|
|
302
|
-
}, _errorFactory)) && ("number" === typeof input.startLine || _a._assertGuard(_exceptionable, {
|
|
301
|
+
const _ao4 = (input, _path, _exceptionable = true) => _ap1(input, _path, true && _exceptionable) && ("number" === typeof input.startLine || _a._assertGuard(_exceptionable, {
|
|
303
302
|
method: "typia.assert",
|
|
304
303
|
path: _path + ".startLine",
|
|
305
304
|
expected: "number",
|
|
@@ -330,28 +329,13 @@ function parseDump(json) {
|
|
|
330
329
|
path: _path + ".to",
|
|
331
330
|
expected: "string",
|
|
332
331
|
value: input.to
|
|
333
|
-
}, _errorFactory)) && (true ===
|
|
332
|
+
}, _errorFactory)) && (true === _av2.has(input.kind) || _a._assertGuard(_exceptionable, {
|
|
334
333
|
method: "typia.assert",
|
|
335
334
|
path: _path + ".kind",
|
|
336
|
-
expected:
|
|
335
|
+
expected: _ae2,
|
|
337
336
|
value: input.kind
|
|
338
|
-
}, _errorFactory)) && (
|
|
339
|
-
|
|
340
|
-
path: _path + ".evidence",
|
|
341
|
-
expected: "(ITtscGraphEvidence | undefined)",
|
|
342
|
-
value: input.evidence
|
|
343
|
-
}, _errorFactory)) && _ao4(input.evidence, _path + ".evidence", true && _exceptionable) || _a._assertGuard(_exceptionable, {
|
|
344
|
-
method: "typia.assert",
|
|
345
|
-
path: _path + ".evidence",
|
|
346
|
-
expected: "(ITtscGraphEvidence | undefined)",
|
|
347
|
-
value: input.evidence
|
|
348
|
-
}, _errorFactory));
|
|
349
|
-
const _ao6 = (input, _path, _exceptionable = true) => ("string" === typeof input.file || _a._assertGuard(_exceptionable, {
|
|
350
|
-
method: "typia.assert",
|
|
351
|
-
path: _path + ".file",
|
|
352
|
-
expected: "string",
|
|
353
|
-
value: input.file
|
|
354
|
-
}, _errorFactory)) && ("number" === typeof input.line || _a._assertGuard(_exceptionable, {
|
|
337
|
+
}, _errorFactory)) && _ap2(input, _path, true && _exceptionable);
|
|
338
|
+
const _ao6 = (input, _path, _exceptionable = true) => _ap1(input, _path, true && _exceptionable) && ("number" === typeof input.line || _a._assertGuard(_exceptionable, {
|
|
355
339
|
method: "typia.assert",
|
|
356
340
|
path: _path + ".line",
|
|
357
341
|
expected: "number",
|
|
@@ -388,12 +372,12 @@ function parseDump(json) {
|
|
|
388
372
|
value: input.node
|
|
389
373
|
}, _errorFactory));
|
|
390
374
|
const _io0 = input => "string" === typeof input.project && "string" === typeof input.tsconfig && (Array.isArray(input.nodes) && input.nodes.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (Array.isArray(input.edges) && input.edges.every(elem => "object" === typeof elem && null !== elem && _io5(elem))) && (undefined === input.diagnostics || Array.isArray(input.diagnostics) && input.diagnostics.every(elem => "object" === typeof elem && null !== elem && _io6(elem)));
|
|
391
|
-
const _io1 = input => "string" === typeof input.id && true ===
|
|
392
|
-
const _io2 = input =>
|
|
375
|
+
const _io1 = input => "string" === typeof input.id && true === _iv0.has(input.kind) && _ip0(input) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName) && _ip1(input) && "boolean" === typeof input.external && (undefined === input.ignored || "boolean" === typeof input.ignored) && (undefined === input.exported || "boolean" === typeof input.exported) && (undefined === input.modifiers || Array.isArray(input.modifiers) && input.modifiers.every(elem => true === _iv1.has(elem))) && (undefined === input.decorators || Array.isArray(input.decorators) && input.decorators.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && _ip2(input) && (undefined === input.implementation || "object" === typeof input.implementation && null !== input.implementation && _io4(input.implementation));
|
|
376
|
+
const _io2 = input => _ip0(input) && (Array.isArray(input.arguments) && input.arguments.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io3(elem)));
|
|
393
377
|
const _io3 = input => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal;
|
|
394
|
-
const _io4 = input =>
|
|
395
|
-
const _io5 = input => "string" === typeof input.from && "string" === typeof input.to && true ===
|
|
396
|
-
const _io6 = input =>
|
|
378
|
+
const _io4 = input => _ip1(input) && "number" === typeof input.startLine && (undefined === input.startCol || "number" === typeof input.startCol) && (undefined === input.endLine || "number" === typeof input.endLine) && (undefined === input.endCol || "number" === typeof input.endCol);
|
|
379
|
+
const _io5 = input => "string" === typeof input.from && "string" === typeof input.to && true === _iv2.has(input.kind) && _ip2(input);
|
|
380
|
+
const _io6 = input => _ip1(input) && "number" === typeof input.line && (undefined === input.column || "number" === typeof input.column) && ("string" === typeof input.code || "number" === typeof input.code) && "string" === typeof input.message && (undefined === input.severity || "error" === input.severity || "hint" === input.severity || "info" === input.severity || "warning" === input.severity) && (undefined === input.origin || "lint" === input.origin || "plugin" === input.origin || "tsc" === input.origin) && (undefined === input.node || "string" === typeof input.node);
|
|
397
381
|
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
398
382
|
let _errorFactory;
|
|
399
383
|
return (input, errorFactory) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadGraph.js","sourceRoot":"","sources":["../../src/model/loadGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC7C,CAAC"}
|
package/lib/reduce.js
CHANGED
|
@@ -8,6 +8,10 @@ exports.reduce = reduce;
|
|
|
8
8
|
function posix(p) {
|
|
9
9
|
return p.replace(/\\/g, "/");
|
|
10
10
|
}
|
|
11
|
+
/** An absolute path (POSIX or Windows drive); relative dumps skip rerooting. */
|
|
12
|
+
function isAbsolute(p) {
|
|
13
|
+
return /^(?:[A-Za-z]:)?\//.test(posix(p));
|
|
14
|
+
}
|
|
11
15
|
function commonRoot(files) {
|
|
12
16
|
if (files.length === 0)
|
|
13
17
|
return "";
|
|
@@ -23,10 +27,14 @@ function commonRoot(files) {
|
|
|
23
27
|
}
|
|
24
28
|
return parts.join("/");
|
|
25
29
|
}
|
|
30
|
+
// An empty root means the dump's paths are already project-relative (the
|
|
31
|
+
// current `ttscgraph dump` contract); they pass through structure-intact.
|
|
26
32
|
function relativize(abs, root) {
|
|
27
33
|
const a = posix(abs);
|
|
28
34
|
const r = posix(root).replace(/\/+$/, "");
|
|
29
|
-
if (r
|
|
35
|
+
if (!r)
|
|
36
|
+
return a;
|
|
37
|
+
if (a === r || a.startsWith(r + "/"))
|
|
30
38
|
return a.slice(r.length).replace(/^\/+/, "");
|
|
31
39
|
const nm = a.lastIndexOf("node_modules/");
|
|
32
40
|
if (nm >= 0)
|
|
@@ -50,9 +58,32 @@ function degreeOf(nodes, edges) {
|
|
|
50
58
|
}
|
|
51
59
|
return degree;
|
|
52
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Collapse the fine-grained wire kinds `ttscgraph dump` emits (calls,
|
|
63
|
+
* instantiates, renders, accesses, type_ref, extends, implements) into the
|
|
64
|
+
* three display families the viewer colors and its legend name. An unknown kind
|
|
65
|
+
* passes through and renders with the fallback color.
|
|
66
|
+
*/
|
|
67
|
+
const DISPLAY_KIND = {
|
|
68
|
+
calls: "value-call",
|
|
69
|
+
instantiates: "value-call",
|
|
70
|
+
renders: "value-call",
|
|
71
|
+
accesses: "value-call",
|
|
72
|
+
type_ref: "type-ref",
|
|
73
|
+
extends: "heritage",
|
|
74
|
+
implements: "heritage",
|
|
75
|
+
};
|
|
76
|
+
function displayKind(kind) {
|
|
77
|
+
return DISPLAY_KIND[kind] ?? kind;
|
|
78
|
+
}
|
|
53
79
|
function reduce(raw, { maxNodes = 1200, keepExternal = false, } = {}) {
|
|
54
80
|
const keptByExternal = raw.nodes.filter((n) => keepExternal || !n.external);
|
|
55
|
-
|
|
81
|
+
// Reroot only absolute paths (the legacy dump contract); a current dump's
|
|
82
|
+
// paths are already project-relative and keep their structure as-is.
|
|
83
|
+
const projectFiles = raw.nodes.filter((n) => !n.external).map((n) => n.file);
|
|
84
|
+
const root = projectFiles.length > 0 && isAbsolute(projectFiles[0])
|
|
85
|
+
? commonRoot(projectFiles)
|
|
86
|
+
: "";
|
|
56
87
|
const liveIds = new Set(keptByExternal.map((n) => n.id));
|
|
57
88
|
const liveEdges = raw.edges.filter((e) => liveIds.has(e.from) && liveIds.has(e.to));
|
|
58
89
|
const degree = degreeOf(keptByExternal, liveEdges);
|
|
@@ -81,7 +112,7 @@ function reduce(raw, { maxNodes = 1200, keepExternal = false, } = {}) {
|
|
|
81
112
|
.map((e) => ({
|
|
82
113
|
source: rewriteId(e.from, root),
|
|
83
114
|
target: rewriteId(e.to, root),
|
|
84
|
-
kind: e.kind,
|
|
115
|
+
kind: displayKind(e.kind),
|
|
85
116
|
}))
|
|
86
117
|
.filter((e) => nodeIds.has(e.source) && nodeIds.has(e.target));
|
|
87
118
|
return {
|
package/lib/reduce.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduce.js","sourceRoot":"","sources":["../src/reduce.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,mEAAmE;;;AAkDnE,SAAS,KAAK,CAAC,CAAS;IACtB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,U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