@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
|
@@ -2,154 +2,146 @@ import { ITtscGraphDetails } from "./ITtscGraphDetails";
|
|
|
2
2
|
import { ITtscGraphEntrypoints } from "./ITtscGraphEntrypoints";
|
|
3
3
|
import { ITtscGraphEscape } from "./ITtscGraphEscape";
|
|
4
4
|
import { ITtscGraphLookup } from "./ITtscGraphLookup";
|
|
5
|
+
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
5
6
|
import { ITtscGraphOverview } from "./ITtscGraphOverview";
|
|
6
7
|
import { ITtscGraphTour } from "./ITtscGraphTour";
|
|
7
8
|
import { ITtscGraphTrace } from "./ITtscGraphTrace";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* ##
|
|
11
|
+
* ## Code Graph MCP
|
|
11
12
|
*
|
|
12
13
|
* `inspect_typescript_graph` returns a compiler-built TypeScript graph contract
|
|
13
|
-
* for the current on-disk source snapshot.
|
|
14
|
-
* server checks project configs, root files, module-resolution inputs, and all
|
|
15
|
-
* resident source contents, then incrementally refreshes or safely reloads.
|
|
14
|
+
* for the current on-disk source snapshot.
|
|
16
15
|
*
|
|
17
16
|
* Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
18
17
|
* type relations. It returns answer-ready index evidence: names, edges,
|
|
19
18
|
* signatures, decorators, tests, spans, and anchors.
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* -
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* - Explain the central path first, then mention important branches.
|
|
93
|
-
* - For tests, impact, or reading lists, returned nodes and ranges are the answer
|
|
94
|
-
* evidence, not search keywords.
|
|
95
|
-
* - A returned range is a sacred citation anchor, not permission to open the
|
|
96
|
-
* file.
|
|
20
|
+
* Every returned fact — each name, edge, signature, and span — is
|
|
21
|
+
* compiler-resolved and verified for the snapshot that call synchronized, so
|
|
22
|
+
* trust it without re-checking against files. Where an operation ranks a
|
|
23
|
+
* shortlist against your question (`lookup`, `entrypoints`, `tour`), the facts
|
|
24
|
+
* stay verified but the selection is heuristic: judge whether its coverage
|
|
25
|
+
* answers you, and a follow-up request or a read of a cited span is fair when
|
|
26
|
+
* it does not.
|
|
27
|
+
*
|
|
28
|
+
* ## Requests
|
|
29
|
+
*
|
|
30
|
+
* A request is a union: pick the single type below that best fits the question,
|
|
31
|
+
* and submit exactly that one.
|
|
32
|
+
*
|
|
33
|
+
* - `tour`: architecture, runtime flow, orientation, or a code tour. One call is
|
|
34
|
+
* the whole answer; do not split it. Name the machinery you expect it to be
|
|
35
|
+
* made of in its `reinterpretations`, or send none.
|
|
36
|
+
* - `entrypoints`: find where execution starts when entry points are unknown.
|
|
37
|
+
* - `lookup`: locate a named symbol.
|
|
38
|
+
* - `trace`: follow calls or data flow forward or backward from a symbol, or —
|
|
39
|
+
* with `to` — the path between two symbols when both ends are known, which is
|
|
40
|
+
* the one call that answers "how does A reach B".
|
|
41
|
+
* - `details`: signatures, members, and relations of named symbols — including
|
|
42
|
+
* the classes that implement an interface, which is the one call that answers
|
|
43
|
+
* "what actually implements this".
|
|
44
|
+
* - `overview`: project layers and folder structure.
|
|
45
|
+
* - `escape`: the answer is outside the graph (source body text, non-TypeScript
|
|
46
|
+
* files, exact search).
|
|
47
|
+
*
|
|
48
|
+
* ## Chain of Thought
|
|
49
|
+
*
|
|
50
|
+
* Fill these fields in order before the call; each one narrows the reasoning
|
|
51
|
+
* toward the single request you submit.
|
|
52
|
+
*
|
|
53
|
+
* - `question`: the code question, in the user's own words.
|
|
54
|
+
* - `draft`: `{ reason, type }` — why the smallest request that could answer it,
|
|
55
|
+
* then that request's `type`.
|
|
56
|
+
* - `review`: fix a broad, stale, or duplicate draft. If the graph already
|
|
57
|
+
* answered, or the evidence is outside it, escape.
|
|
58
|
+
* - `request`: the final choice. Each branch documents its own fields; fill them
|
|
59
|
+
* from what the branch says, not from what another branch wanted.
|
|
60
|
+
*
|
|
61
|
+
* ## What to trust
|
|
62
|
+
*
|
|
63
|
+
* Before source edits, every returned fact is compiler-resolved and verified.
|
|
64
|
+
* Never use extra graph calls, repository search, or file reads to doubt,
|
|
65
|
+
* fact-check, re-derive, re-narrate, or re-confirm a returned node, span, edge,
|
|
66
|
+
* signature, decorator, test, reference, step, or anchor. The server resolved
|
|
67
|
+
* each one to the type-checked program for the snapshot the call synced to, and
|
|
68
|
+
* `audit` says so on every result.
|
|
69
|
+
*
|
|
70
|
+
* Selection is the separate question. `lookup`, `entrypoints`, and `tour` match
|
|
71
|
+
* your question and return a scored, ranked, per-file-capped, limited
|
|
72
|
+
* shortlist; their facts are still verified, but whether the shortlist covers
|
|
73
|
+
* what you asked is yours to judge, and their `audit` says that instead of
|
|
74
|
+
* claiming completeness. A follow-up request or a read of a cited span for
|
|
75
|
+
* missed coverage is legitimate — re-confirming a fact the graph already
|
|
76
|
+
* resolved is not.
|
|
77
|
+
*
|
|
78
|
+
* ## Stop
|
|
79
|
+
*
|
|
80
|
+
* Let the result's `next` set the pace, and do not re-confirm what the graph
|
|
81
|
+
* resolved.
|
|
82
|
+
*
|
|
83
|
+
* - A span is a citation, not a cue to open the file to re-check a fact.
|
|
84
|
+
* - Follow the result's `next`: `answer` means stop and answer from it, `inspect`
|
|
85
|
+
* means make exactly the one request it names, `outside` means escape,
|
|
86
|
+
* `clarify` means restate the request.
|
|
87
|
+
* - For a ranked shortlist (`lookup`, `entrypoints`, `tour`), `next` and
|
|
88
|
+
* `truncated` say whether coverage is settled; when it is not, one more
|
|
89
|
+
* request is the right move — not a file read to re-verify facts already
|
|
90
|
+
* given.
|
|
97
91
|
*/
|
|
98
92
|
export interface ITtscGraphApplication {
|
|
99
93
|
/**
|
|
100
|
-
*
|
|
94
|
+
* Answer a TypeScript question from the compiler's own index of this
|
|
95
|
+
* repository.
|
|
101
96
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* broad runtime flow questions, use `tour`.
|
|
97
|
+
* The graph holds every symbol, call, type, decorator and test, each with its
|
|
98
|
+
* file and line, resolved from the source on disk now. Submit exactly one
|
|
99
|
+
* request:
|
|
106
100
|
*
|
|
107
|
-
*
|
|
108
|
-
* the
|
|
109
|
-
*
|
|
110
|
-
*
|
|
101
|
+
* - `tour`: architecture, the runtime flow from the public API to the code that
|
|
102
|
+
* does the work, nearby paths, and the tests to read — a whole orientation
|
|
103
|
+
* in one call
|
|
104
|
+
* - `trace`: what a symbol calls, what calls it, or the path from A to B
|
|
105
|
+
* - `details`: signatures, members, and what implements an interface
|
|
106
|
+
* - `lookup`: where a named symbol is declared
|
|
107
|
+
* - `entrypoints`: where execution starts, when the entry is unknown
|
|
108
|
+
* - `overview`: the project's layers and folder structure
|
|
109
|
+
*
|
|
110
|
+
* Every fact in a result is the checker's own resolution, audited before
|
|
111
|
+
* return, so no fact needs verifying; for the ranked operations (`lookup`,
|
|
112
|
+
* `entrypoints`, `tour`), judge whether the shortlist covers your question.
|
|
113
|
+
* Read a file for what the graph does not carry: a body, the text in a span.
|
|
111
114
|
*
|
|
112
115
|
* @param props Reasoning plus one graph request
|
|
113
116
|
* @returns Matching `result` union member
|
|
114
117
|
*/
|
|
115
118
|
inspect_typescript_graph(
|
|
116
119
|
props: ITtscGraphApplication.IProps,
|
|
117
|
-
): Promise<ITtscGraphApplication.
|
|
120
|
+
): Promise<ITtscGraphApplication.IOutput>;
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
export namespace ITtscGraphApplication {
|
|
121
124
|
/** Draft, review, then submit exactly one graph request or escape. */
|
|
122
125
|
export interface IProps {
|
|
123
126
|
/**
|
|
124
|
-
*
|
|
127
|
+
* The code question, in the user's own words.
|
|
125
128
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
+
* Cut a long message down to the sentences that state the ask, but keep
|
|
130
|
+
* their terms: the graph ranks against these words, so a rewrite ranks a
|
|
131
|
+
* different answer.
|
|
129
132
|
*/
|
|
130
133
|
question: string;
|
|
131
134
|
|
|
132
|
-
/**
|
|
133
|
-
* Initial request plan before final arguments are filled.
|
|
134
|
-
*
|
|
135
|
-
* Name the intended request type in `type` and why it seems smallest in
|
|
136
|
-
* `reason`. Broad flow, architecture, repository-orientation, and read-next
|
|
137
|
-
* questions should normally draft `tour`; narrow named symbols can draft
|
|
138
|
-
* `lookup`, `trace`, or `details`.
|
|
139
|
-
*/
|
|
135
|
+
/** The smallest request that could answer, and why. */
|
|
140
136
|
draft: IDraft;
|
|
141
137
|
|
|
142
138
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* Correct a stale, broad, duplicate, or wrong draft here. If broad flow was
|
|
146
|
-
* split into search/detail steps, switch to `tour`. If graph facts already
|
|
147
|
-
* answer, or prior `next.action` was `answer`, make `request.type` be
|
|
148
|
-
* `escape`; do not call graph or read files to re-confirm returned facts.
|
|
139
|
+
* Correct the draft. Escape if the graph already answered, or the next
|
|
140
|
+
* evidence is outside the graph.
|
|
149
141
|
*/
|
|
150
142
|
review: string;
|
|
151
143
|
|
|
152
|
-
/** Final graph
|
|
144
|
+
/** Final graph request chosen after review, or a no-op escape. */
|
|
153
145
|
request:
|
|
154
146
|
| ITtscGraphEntrypoints.IRequest
|
|
155
147
|
| ITtscGraphLookup.IRequest
|
|
@@ -160,22 +152,36 @@ export namespace ITtscGraphApplication {
|
|
|
160
152
|
| ITtscGraphEscape.IRequest;
|
|
161
153
|
}
|
|
162
154
|
|
|
163
|
-
/**
|
|
164
|
-
* First-pass request plan, filled before the final `request` arguments.
|
|
165
|
-
*
|
|
166
|
-
* `reason` comes before `type` so the justification is written before the
|
|
167
|
-
* choice it justifies.
|
|
168
|
-
*/
|
|
155
|
+
/** First-pass plan; `reason` precedes `type` so it is written first. */
|
|
169
156
|
export interface IDraft {
|
|
170
|
-
/** Why this
|
|
157
|
+
/** Why this is the smallest useful next step. */
|
|
171
158
|
reason: string;
|
|
172
159
|
|
|
173
|
-
/** The request type being considered
|
|
160
|
+
/** The request type being considered. */
|
|
174
161
|
type: IProps["request"]["type"];
|
|
175
162
|
}
|
|
176
163
|
|
|
177
164
|
/** The selected request's output. `result.type` mirrors `request.type`. */
|
|
178
|
-
export interface
|
|
165
|
+
export interface IOutput {
|
|
166
|
+
/**
|
|
167
|
+
* What the server audited this result against before returning it, in its
|
|
168
|
+
* own words: every node, span, edge, signature, member, and step in it
|
|
169
|
+
* resolves to the type-checked program for the snapshot the call synced to,
|
|
170
|
+
* so opening a file it cites only returns a fact already in it.
|
|
171
|
+
*
|
|
172
|
+
* The audit is operation-aware. For the exact operations (`trace`,
|
|
173
|
+
* `details`, `overview`) it reports the result as the structure the graph
|
|
174
|
+
* holds for the handles named, bounded only where `truncated` says. For the
|
|
175
|
+
* ranked operations (`lookup`, `entrypoints`, `tour`) it adds that the
|
|
176
|
+
* selection is heuristic — matched, scored, ranked, and limited against the
|
|
177
|
+
* question — so the facts are verified but the shortlist's coverage is the
|
|
178
|
+
* caller's to judge.
|
|
179
|
+
*/
|
|
180
|
+
audit: string;
|
|
181
|
+
|
|
182
|
+
/** What to do with `result`: answer, inspect one named request, or escape. */
|
|
183
|
+
next: ITtscGraphNext;
|
|
184
|
+
|
|
179
185
|
/** Result branch matching the submitted `request.type`. */
|
|
180
186
|
result:
|
|
181
187
|
| ITtscGraphEntrypoints
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A decorator as written on a declaration, carried on the decorated
|
|
3
|
-
* {@link ITtscGraphNode}'s `decorators`.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `Get`, `TypedRoute.Get`, ...), and statically resolvable literal arguments
|
|
8
|
-
* are preserved so a consumer can apply its own meaning without re-parsing
|
|
9
|
-
* source.
|
|
3
|
+
* {@link ITtscGraphNode}'s `decorators`. Reported faithfully, not interpreted
|
|
4
|
+
* per framework: `name` is the decorator as written (`Controller`, `Get`,
|
|
5
|
+
* `TypedRoute.Get`, ...), and statically resolvable literal arguments are
|
|
6
|
+
* preserved so a consumer applies its own meaning without re-parsing source.
|
|
10
7
|
*/
|
|
11
8
|
export interface ITtscGraphDecorator {
|
|
12
9
|
/**
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
|
|
2
2
|
import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
|
|
3
|
-
import { ITtscGraphNext } from "./ITtscGraphNext";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* calls, direct types, implementation candidates, dependency summaries, and
|
|
10
|
-
* sourceSpan citation anchors.
|
|
5
|
+
* Source-free facts for a few selected handles, not a file reader: signatures,
|
|
6
|
+
* member outlines, direct calls and types, implementation candidates,
|
|
7
|
+
* dependency summaries, and sourceSpan citation anchors.
|
|
11
8
|
*/
|
|
12
9
|
export interface ITtscGraphDetails {
|
|
13
10
|
/** Discriminator for selected symbol inspection. */
|
|
@@ -16,14 +13,19 @@ export interface ITtscGraphDetails {
|
|
|
16
13
|
/** Selected node facts, in the same order as resolved handles when possible. */
|
|
17
14
|
nodes: ITtscGraphDetails.INode[];
|
|
18
15
|
|
|
19
|
-
/**
|
|
20
|
-
next: ITtscGraphNext;
|
|
21
|
-
|
|
22
|
-
/** Human-readable compatibility note mirroring `next`. */
|
|
23
|
-
guide: string;
|
|
24
|
-
|
|
25
|
-
/** Handles that resolved to no node, or that were ambiguous. */
|
|
16
|
+
/** Handles the graph holds no node for. */
|
|
26
17
|
unknown: string[];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Handles that name more than one node, with the nodes they name.
|
|
21
|
+
*
|
|
22
|
+
* A name the graph knows twice is not a name the graph does not know: two
|
|
23
|
+
* classes called `Workbench` are two facts, and answering "unknown" to a
|
|
24
|
+
* handle the checker resolved twice sends the caller to the files for what is
|
|
25
|
+
* already here. Re-call `details` with the `id` of the one the question
|
|
26
|
+
* means.
|
|
27
|
+
*/
|
|
28
|
+
ambiguous?: ITtscGraphDetails.IAmbiguity[];
|
|
27
29
|
}
|
|
28
30
|
export namespace ITtscGraphDetails {
|
|
29
31
|
/** Which selected handles to inspect, and how much of each to return. */
|
|
@@ -32,47 +34,37 @@ export namespace ITtscGraphDetails {
|
|
|
32
34
|
type: "details";
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
|
-
* Node ids
|
|
36
|
-
* `
|
|
37
|
-
* details. Prefer one to three handles. Use `trace` when you need a path
|
|
38
|
-
* instead of widening this call.
|
|
37
|
+
* Node ids or dotted symbol handles (`OrderService.create`). Prefer one to
|
|
38
|
+
* three; use `trace` for a path instead of widening this call.
|
|
39
39
|
*/
|
|
40
40
|
handles: string[];
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Also list each node's direct dependencies and dependents (
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* relation is named. This remains a relationship summary, not a file body.
|
|
43
|
+
* Also list each node's direct dependencies and dependents (symbols it uses
|
|
44
|
+
* and symbols that use it), capped. A relationship summary, not a file
|
|
45
|
+
* body.
|
|
47
46
|
*
|
|
48
47
|
* @default false
|
|
49
48
|
*/
|
|
50
49
|
neighbors?: boolean;
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
|
-
* Maximum dependencies and dependents
|
|
54
|
-
* `
|
|
55
|
-
*
|
|
56
|
-
* Prefer the default. Values above a few neighbors are usually overfetch;
|
|
57
|
-
* call `trace` for flow instead.
|
|
52
|
+
* Maximum dependencies and dependents per side when `neighbors:true`. Above
|
|
53
|
+
* a few is usually overfetch; call `trace` for flow instead.
|
|
58
54
|
*
|
|
59
55
|
* @default 2
|
|
60
56
|
*/
|
|
61
57
|
neighborLimit?: number;
|
|
62
58
|
|
|
63
59
|
/**
|
|
64
|
-
* Maximum owned members
|
|
65
|
-
* only when the first outline is truncated and the missing member is
|
|
66
|
-
* named.
|
|
60
|
+
* Maximum owned members for a container or object literal.
|
|
67
61
|
*
|
|
68
62
|
* @default 6
|
|
69
63
|
*/
|
|
70
64
|
memberLimit?: number;
|
|
71
65
|
|
|
72
66
|
/**
|
|
73
|
-
* Maximum direct execution and type references
|
|
74
|
-
* only when the first dependency slice is truncated and the missing
|
|
75
|
-
* dependency is named.
|
|
67
|
+
* Maximum direct execution and type references per group.
|
|
76
68
|
*
|
|
77
69
|
* @default 1
|
|
78
70
|
*/
|
|
@@ -80,14 +72,41 @@ export namespace ITtscGraphDetails {
|
|
|
80
72
|
|
|
81
73
|
/**
|
|
82
74
|
* Include dependency-boundary references from node_modules or bundled
|
|
83
|
-
* `.d.ts` libraries.
|
|
84
|
-
*
|
|
75
|
+
* `.d.ts` libraries. Enable only when external type/API boundaries are the
|
|
76
|
+
* question.
|
|
85
77
|
*
|
|
86
78
|
* @default false
|
|
87
79
|
*/
|
|
88
80
|
includeExternal?: boolean;
|
|
89
81
|
}
|
|
90
82
|
|
|
83
|
+
/** One handle and the several nodes it names. */
|
|
84
|
+
export interface IAmbiguity {
|
|
85
|
+
/** The handle as submitted. */
|
|
86
|
+
handle: string;
|
|
87
|
+
|
|
88
|
+
/** Every node the handle names, each with the id to re-call `details` on. */
|
|
89
|
+
candidates: ICandidate[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** One node a handle could mean: enough to choose, not to answer from. */
|
|
93
|
+
export interface ICandidate {
|
|
94
|
+
/** Stable node id: submit this as the handle to select this one. */
|
|
95
|
+
id: string;
|
|
96
|
+
|
|
97
|
+
/** Qualified symbol name when available, otherwise the simple name. */
|
|
98
|
+
name: string;
|
|
99
|
+
|
|
100
|
+
/** Declaration kind (`class`, `method`, `function`, ...). */
|
|
101
|
+
kind: string;
|
|
102
|
+
|
|
103
|
+
/** Project-relative path of the file that declares this node. */
|
|
104
|
+
file: string;
|
|
105
|
+
|
|
106
|
+
/** 1-based declaration line, when known. */
|
|
107
|
+
line?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
91
110
|
/** One inspected node: its declared shape and graph coordinates. */
|
|
92
111
|
export interface INode {
|
|
93
112
|
/** Stable node id for subsequent `details` or `trace` calls. */
|
|
@@ -108,6 +127,9 @@ export namespace ITtscGraphDetails {
|
|
|
108
127
|
/** The declaration signature: its first line(s) up to the body. */
|
|
109
128
|
signature?: string;
|
|
110
129
|
|
|
130
|
+
/** The first sentence of the doc comment above the declaration. */
|
|
131
|
+
doc?: string;
|
|
132
|
+
|
|
111
133
|
/** Decorators written on this declaration, when any. */
|
|
112
134
|
decorators?: ITtscGraphDecorator[];
|
|
113
135
|
|
|
@@ -127,8 +149,8 @@ export namespace ITtscGraphDetails {
|
|
|
127
149
|
literals?: string[];
|
|
128
150
|
|
|
129
151
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
152
|
+
* Owned symbol or top-level property outline a consumer reaches for on a
|
|
153
|
+
* container or object-literal variable, without bodies.
|
|
132
154
|
*/
|
|
133
155
|
members?: IMember[];
|
|
134
156
|
|
|
@@ -181,17 +203,9 @@ export namespace ITtscGraphDetails {
|
|
|
181
203
|
relation: string;
|
|
182
204
|
|
|
183
205
|
/**
|
|
184
|
-
* Source span
|
|
185
|
-
*
|
|
206
|
+
* Source span that produced the edge: citation evidence, not a file-read
|
|
207
|
+
* cue.
|
|
186
208
|
*/
|
|
187
209
|
evidence?: ITtscGraphEvidence;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Stable access-path aliases derived from edge evidence. For example, an
|
|
191
|
-
* edge to `Owner.member` through `obj.slot.member` may expose
|
|
192
|
-
* `Owner.slot.member` so answers can preserve both the resolved symbol and
|
|
193
|
-
* the source access path.
|
|
194
|
-
*/
|
|
195
|
-
aliases?: string[];
|
|
196
210
|
}
|
|
197
211
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ITtscGraphDiagnostic } from "./ITtscGraphDiagnostic";
|
|
2
1
|
import { ITtscGraphEdge } from "./ITtscGraphEdge";
|
|
3
2
|
import { ITtscGraphNode } from "./ITtscGraphNode";
|
|
3
|
+
import { ITtscGraphSpan } from "./ITtscGraphSpan";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The whole-graph export `ttscgraph dump` writes and the MCP server loads — the
|
|
@@ -12,8 +12,8 @@ import { ITtscGraphNode } from "./ITtscGraphNode";
|
|
|
12
12
|
* that warm model while project inputs stay unchanged; the bundled 3D viewer
|
|
13
13
|
* reduces the same dump.
|
|
14
14
|
*
|
|
15
|
-
* Paths in `project` and `tsconfig` are absolute; `file` fields on nodes
|
|
16
|
-
* edges
|
|
15
|
+
* Paths in `project` and `tsconfig` are absolute; `file` fields on nodes and
|
|
16
|
+
* edges are project-relative.
|
|
17
17
|
*/
|
|
18
18
|
export interface ITtscGraphDump {
|
|
19
19
|
/** Absolute path of the project root the graph was built for. */
|
|
@@ -23,14 +23,43 @@ export interface ITtscGraphDump {
|
|
|
23
23
|
tsconfig: string;
|
|
24
24
|
|
|
25
25
|
/** Every node the build recorded. */
|
|
26
|
-
nodes:
|
|
26
|
+
nodes: ITtscGraphDump.INode[];
|
|
27
27
|
|
|
28
28
|
/** Every edge the build resolved. */
|
|
29
|
-
edges:
|
|
29
|
+
edges: ITtscGraphDump.IEdge[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace ITtscGraphDump {
|
|
33
|
+
/**
|
|
34
|
+
* A node as the builder sends it: the graph node, minus the file paths inside
|
|
35
|
+
* its spans, which the loader puts back from the node's own `file`.
|
|
36
|
+
*
|
|
37
|
+
* A node's declaration span is in the node's file, always — the path in the
|
|
38
|
+
* span was the same string a second time, once per node. It is the reader's
|
|
39
|
+
* to reconstruct, and {@link TtscGraphMemory} does, so nothing downstream of
|
|
40
|
+
* the loader sees a span without its file.
|
|
41
|
+
*/
|
|
42
|
+
export interface INode extends Omit<
|
|
43
|
+
ITtscGraphNode,
|
|
44
|
+
"evidence" | "implementation"
|
|
45
|
+
> {
|
|
46
|
+
/** Declaration span; its file is this node's `file`. */
|
|
47
|
+
evidence?: ITtscGraphSpan;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Implementation span. This one keeps its file when it has one: an
|
|
51
|
+
* implementation genuinely can live in another file from its declaration.
|
|
52
|
+
*/
|
|
53
|
+
implementation?: ITtscGraphSpan;
|
|
54
|
+
}
|
|
30
55
|
|
|
31
56
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
57
|
+
* An edge as the builder sends it. Its span is in the file its `from` id
|
|
58
|
+
* names — the id is `path#Qualified.Name:kind` — so the path rode the wire a
|
|
59
|
+
* second time on every edge, and edges outnumber nodes several times over.
|
|
34
60
|
*/
|
|
35
|
-
|
|
61
|
+
export interface IEdge extends Omit<ITtscGraphEdge, "evidence"> {
|
|
62
|
+
/** Expression span; its file is the one embedded in `from`. */
|
|
63
|
+
evidence?: ITtscGraphSpan;
|
|
64
|
+
}
|
|
36
65
|
}
|
|
@@ -2,12 +2,10 @@ import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
|
|
|
2
2
|
import { TtscGraphEdgeKind } from "./TtscGraphEdgeKind";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* A directed relationship
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Every edge is resolved by the compiler, so there is no per-edge trust flag to
|
|
10
|
-
* carry — the whole graph is checker-resolved fact.
|
|
5
|
+
* A directed relationship between two {@link ITtscGraphNode}s, both named by
|
|
6
|
+
* `id`. The triple `(from, to, kind)` is unique; a repeat keeps the first
|
|
7
|
+
* source-order evidence. Every edge is compiler-resolved, so there is no
|
|
8
|
+
* per-edge trust flag: the whole graph is checker-resolved fact.
|
|
11
9
|
*/
|
|
12
10
|
export interface ITtscGraphEdge {
|
|
13
11
|
/** Node id the relationship originates from. */
|