@ttsc/graph 0.18.3 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +231 -36
- package/lib/TtscGraphApplication.d.ts +4 -3
- package/lib/TtscGraphApplication.js +54 -19
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/index.d.ts +9 -4
- package/lib/index.js +24 -5
- package/lib/index.js.map +1 -1
- package/lib/model/TtscGraphMemory.js +80 -22
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphSession.d.ts +36 -0
- package/lib/model/TtscGraphSession.js +457 -0
- package/lib/model/TtscGraphSession.js.map +1 -0
- package/lib/model/loadGraph.d.ts +3 -3
- package/lib/model/loadGraph.js +94 -141
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/resolveGraphBinary.d.ts +4 -2
- package/lib/resolveGraphBinary.js +7 -3
- package/lib/resolveGraphBinary.js.map +1 -1
- package/lib/server/createServer.d.ts +16 -9
- package/lib/server/createServer.js +286 -190
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/exportSurface.d.ts +26 -0
- package/lib/server/exportSurface.js +44 -0
- package/lib/server/exportSurface.js.map +1 -0
- package/lib/server/resolveHandle.d.ts +26 -1
- package/lib/server/resolveHandle.js +124 -4
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +74 -0
- package/lib/server/resultAudit.js +110 -0
- package/lib/server/resultAudit.js.map +1 -0
- package/lib/server/resultNext.d.ts +9 -0
- package/lib/server/resultNext.js +11 -0
- package/lib/server/resultNext.js.map +1 -0
- package/lib/server/runDetails.d.ts +15 -3
- package/lib/server/runDetails.js +105 -23
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.d.ts +2 -1
- package/lib/server/runEntrypoints.js +17 -10
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.d.ts +2 -1
- package/lib/server/runLookup.js +21 -9
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runOverview.d.ts +2 -1
- package/lib/server/runOverview.js +5 -4
- package/lib/server/runOverview.js.map +1 -1
- package/lib/server/runTour.d.ts +2 -1
- package/lib/server/runTour.js +707 -331
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +2 -1
- package/lib/server/runTrace.js +234 -54
- package/lib/server/runTrace.js.map +1 -1
- package/lib/server/startServer.d.ts +3 -2
- package/lib/server/startServer.js +13 -7
- package/lib/server/startServer.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +122 -114
- package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
- package/lib/structures/ITtscGraphDetails.d.ts +51 -43
- package/lib/structures/ITtscGraphDump.d.ts +36 -11
- package/lib/structures/ITtscGraphEdge.d.ts +4 -6
- package/lib/structures/ITtscGraphEntrypoints.d.ts +10 -27
- package/lib/structures/ITtscGraphEscape.d.ts +6 -16
- package/lib/structures/ITtscGraphEvidence.d.ts +5 -8
- package/lib/structures/ITtscGraphLookup.d.ts +9 -20
- package/lib/structures/ITtscGraphNext.d.ts +10 -7
- package/lib/structures/ITtscGraphNode.d.ts +17 -8
- package/lib/structures/ITtscGraphOverview.d.ts +10 -14
- package/lib/structures/ITtscGraphSpan.d.ts +29 -0
- package/lib/structures/{ITtscGraphDiagnostic.js → ITtscGraphSpan.js} +1 -1
- package/lib/structures/ITtscGraphSpan.js.map +1 -0
- package/lib/structures/ITtscGraphTour.d.ts +65 -23
- package/lib/structures/ITtscGraphTrace.d.ts +72 -49
- package/lib/structures/TtscGraphEdgeKind.d.ts +7 -1
- package/lib/structures/index.d.ts +1 -1
- package/lib/structures/index.js +1 -1
- package/lib/structures/index.js.map +1 -1
- package/lib/view.js +3 -1
- package/lib/view.js.map +1 -1
- package/package.json +4 -4
- package/src/TtscGraphApplication.ts +66 -31
- package/src/index.ts +23 -5
- package/src/model/TtscGraphMemory.ts +86 -22
- package/src/model/TtscGraphSession.ts +204 -0
- package/src/model/loadGraph.ts +6 -4
- package/src/resolveGraphBinary.ts +7 -3
- package/src/server/createServer.ts +24 -17
- package/src/server/exportSurface.ts +40 -0
- package/src/server/resolveHandle.ts +141 -4
- package/src/server/resultAudit.ts +109 -0
- package/src/server/resultNext.ts +22 -0
- package/src/server/runDetails.ts +112 -28
- package/src/server/runEntrypoints.ts +26 -17
- package/src/server/runLookup.ts +29 -18
- package/src/server/runOverview.ts +9 -10
- package/src/server/runTour.ts +764 -363
- package/src/server/runTrace.ts +265 -71
- package/src/server/startServer.ts +13 -8
- package/src/structures/ITtscGraphApplication.ts +124 -114
- package/src/structures/ITtscGraphDecorator.ts +4 -7
- package/src/structures/ITtscGraphDetails.ts +60 -46
- package/src/structures/ITtscGraphDump.ts +41 -11
- package/src/structures/ITtscGraphEdge.ts +4 -6
- package/src/structures/ITtscGraphEntrypoints.ts +10 -30
- package/src/structures/ITtscGraphEscape.ts +6 -19
- package/src/structures/ITtscGraphEvidence.ts +5 -8
- package/src/structures/ITtscGraphLookup.ts +9 -22
- package/src/structures/ITtscGraphNext.ts +10 -7
- package/src/structures/ITtscGraphNode.ts +18 -8
- package/src/structures/ITtscGraphOverview.ts +10 -17
- package/src/structures/ITtscGraphSpan.ts +33 -0
- package/src/structures/ITtscGraphTour.ts +70 -28
- package/src/structures/ITtscGraphTrace.ts +82 -51
- package/src/structures/TtscGraphEdgeKind.ts +7 -0
- package/src/structures/index.ts +1 -1
- package/src/view.ts +3 -1
- package/lib/server/accessAliases.d.ts +0 -8
- package/lib/server/accessAliases.js +0 -53
- package/lib/server/accessAliases.js.map +0 -1
- package/lib/server/resultGuide.d.ts +0 -3
- package/lib/server/resultGuide.js +0 -16
- package/lib/server/resultGuide.js.map +0 -1
- package/lib/structures/ITtscGraphDiagnostic.d.ts +0 -27
- package/lib/structures/ITtscGraphDiagnostic.js.map +0 -1
- package/src/server/accessAliases.ts +0 -55
- package/src/server/resultGuide.ts +0 -20
- package/src/structures/ITtscGraphDiagnostic.ts +0 -34
|
@@ -2,20 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.startServer = startServer;
|
|
4
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
|
-
const
|
|
5
|
+
const TtscGraphSession_1 = require("../model/TtscGraphSession");
|
|
6
6
|
const createServer_1 = require("./createServer");
|
|
7
7
|
/**
|
|
8
8
|
* Serve the graph tools over MCP on stdio. The server answers the MCP handshake
|
|
9
|
-
* immediately and
|
|
10
|
-
* project cannot make the client give up before
|
|
9
|
+
* immediately and opens the resident incremental graph session on the first
|
|
10
|
+
* real tool call, so a large project cannot make the client give up before
|
|
11
|
+
* tools are advertised and an escape request still performs no graph work.
|
|
11
12
|
*/
|
|
12
13
|
async function startServer(options) {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const cwd = options.cwd ?? process.cwd();
|
|
15
|
+
const tsconfig = options.tsconfig ?? "tsconfig.json";
|
|
16
|
+
let session;
|
|
17
|
+
const server = (0, createServer_1.createServer)(async () => {
|
|
18
|
+
session ??= new TtscGraphSession_1.TtscGraphSession({ cwd, tsconfig });
|
|
19
|
+
return session.graph();
|
|
17
20
|
}, options.version);
|
|
18
21
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
22
|
+
const closeSession = () => session?.close();
|
|
23
|
+
transport.onclose = closeSession;
|
|
24
|
+
process.stdin.once("end", closeSession);
|
|
19
25
|
await server.connect(transport);
|
|
20
26
|
}
|
|
21
27
|
//# sourceMappingURL=startServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/server/startServer.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;
|
|
1
|
+
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/server/startServer.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AAEjF,gEAA6D;AAC7D,iDAA8C;AAE9C;;;;;GAKG;AACI,KAAK,sBAAsB,OAKjC;IACC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC;IACrD,IAAI,OAAqC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAA,2BAAY,EAAC,KAAK,IAAI,EAAE;QACrC,OAAO,KAAK,IAAI,mCAAgB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5C,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACxC,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -2,159 +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 source snapshot.
|
|
13
|
+
* for the current on-disk source snapshot.
|
|
13
14
|
*
|
|
14
15
|
* Use it for architecture, runtime flow, APIs, callers/callees, code tours, and
|
|
15
16
|
* type relations. It returns answer-ready index evidence: names, edges,
|
|
16
17
|
* signatures, decorators, tests, spans, and anchors.
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
* compiler
|
|
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
|
-
* evidence, not search keywords.
|
|
90
|
-
* - A returned range is a sacred citation anchor, not permission to open the
|
|
91
|
-
* 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.
|
|
92
90
|
*/
|
|
93
91
|
export interface ITtscGraphApplication {
|
|
94
92
|
/**
|
|
95
|
-
*
|
|
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:
|
|
96
99
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
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
|
|
101
108
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
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.
|
|
106
113
|
*
|
|
107
114
|
* @param props Reasoning plus one graph request
|
|
108
115
|
* @returns Matching `result` union member
|
|
109
116
|
*/
|
|
110
|
-
inspect_typescript_graph(props: ITtscGraphApplication.IProps): ITtscGraphApplication.
|
|
117
|
+
inspect_typescript_graph(props: ITtscGraphApplication.IProps): Promise<ITtscGraphApplication.IOutput>;
|
|
111
118
|
}
|
|
112
119
|
export declare namespace ITtscGraphApplication {
|
|
113
120
|
/** Draft, review, then submit exactly one graph request or escape. */
|
|
114
121
|
interface IProps {
|
|
115
122
|
/**
|
|
116
|
-
*
|
|
123
|
+
* The code question, in the user's own words.
|
|
117
124
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
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.
|
|
121
128
|
*/
|
|
122
129
|
question: string;
|
|
123
|
-
/**
|
|
124
|
-
* Initial request plan before final arguments are filled.
|
|
125
|
-
*
|
|
126
|
-
* Name the intended request type in `type` and why it seems smallest in
|
|
127
|
-
* `reason`. Broad flow, architecture, repository-orientation, and read-next
|
|
128
|
-
* questions should normally draft `tour`; narrow named symbols can draft
|
|
129
|
-
* `lookup`, `trace`, or `details`.
|
|
130
|
-
*/
|
|
130
|
+
/** The smallest request that could answer, and why. */
|
|
131
131
|
draft: IDraft;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* Correct a stale, broad, duplicate, or wrong draft here. If broad flow was
|
|
136
|
-
* split into search/detail steps, switch to `tour`. If graph facts already
|
|
137
|
-
* answer, or prior `next.action` was `answer`, make `request.type` be
|
|
138
|
-
* `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.
|
|
139
135
|
*/
|
|
140
136
|
review: string;
|
|
141
|
-
/** Final graph
|
|
137
|
+
/** Final graph request chosen after review, or a no-op escape. */
|
|
142
138
|
request: ITtscGraphEntrypoints.IRequest | ITtscGraphLookup.IRequest | ITtscGraphTrace.IRequest | ITtscGraphDetails.IRequest | ITtscGraphOverview.IRequest | ITtscGraphTour.IRequest | ITtscGraphEscape.IRequest;
|
|
143
139
|
}
|
|
144
|
-
/**
|
|
145
|
-
* First-pass request plan, filled before the final `request` arguments.
|
|
146
|
-
*
|
|
147
|
-
* `reason` comes before `type` so the justification is written before the
|
|
148
|
-
* choice it justifies.
|
|
149
|
-
*/
|
|
140
|
+
/** First-pass plan; `reason` precedes `type` so it is written first. */
|
|
150
141
|
interface IDraft {
|
|
151
|
-
/** Why this
|
|
142
|
+
/** Why this is the smallest useful next step. */
|
|
152
143
|
reason: string;
|
|
153
|
-
/** The request type being considered
|
|
144
|
+
/** The request type being considered. */
|
|
154
145
|
type: IProps["request"]["type"];
|
|
155
146
|
}
|
|
156
147
|
/** The selected request's output. `result.type` mirrors `request.type`. */
|
|
157
|
-
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;
|
|
158
166
|
/** Result branch matching the submitted `request.type`. */
|
|
159
167
|
result: ITtscGraphEntrypoints | ITtscGraphLookup | ITtscGraphTrace | ITtscGraphDetails | ITtscGraphOverview | ITtscGraphTour | ITtscGraphEscape;
|
|
160
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,17 +1,18 @@
|
|
|
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.
|
|
7
7
|
*
|
|
8
8
|
* It is the complete graph with none of the per-response caps the MCP tools
|
|
9
|
-
* apply: every node and edge the build resolved. The server parses
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* apply: every node and edge the build resolved. The server parses each changed
|
|
10
|
+
* native snapshot (typia-validated) into an in-memory resident graph and reuses
|
|
11
|
+
* that warm model while project inputs stay unchanged; the bundled 3D viewer
|
|
12
|
+
* reduces the same dump.
|
|
12
13
|
*
|
|
13
|
-
* Paths in `project` and `tsconfig` are absolute; `file` fields on nodes
|
|
14
|
-
* edges
|
|
14
|
+
* Paths in `project` and `tsconfig` are absolute; `file` fields on nodes and
|
|
15
|
+
* edges are project-relative.
|
|
15
16
|
*/
|
|
16
17
|
export interface ITtscGraphDump {
|
|
17
18
|
/** Absolute path of the project root the graph was built for. */
|
|
@@ -19,12 +20,36 @@ export interface ITtscGraphDump {
|
|
|
19
20
|
/** The tsconfig the program was loaded from, relative to `project`. */
|
|
20
21
|
tsconfig: string;
|
|
21
22
|
/** Every node the build recorded. */
|
|
22
|
-
nodes:
|
|
23
|
+
nodes: ITtscGraphDump.INode[];
|
|
23
24
|
/** Every edge the build resolved. */
|
|
24
|
-
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
|
+
}
|
|
25
46
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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.
|
|
28
50
|
*/
|
|
29
|
-
|
|
51
|
+
interface IEdge extends Omit<ITtscGraphEdge, "evidence"> {
|
|
52
|
+
/** Expression span; its file is the one embedded in `from`. */
|
|
53
|
+
evidence?: ITtscGraphSpan;
|
|
54
|
+
}
|
|
30
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. */
|