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