@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.
Files changed (119) hide show
  1. package/README.md +231 -37
  2. package/lib/TtscGraphApplication.d.ts +1 -1
  3. package/lib/TtscGraphApplication.js +50 -17
  4. package/lib/TtscGraphApplication.js.map +1 -1
  5. package/lib/index.d.ts +5 -0
  6. package/lib/index.js +20 -1
  7. package/lib/index.js.map +1 -1
  8. package/lib/model/TtscGraphMemory.js +80 -22
  9. package/lib/model/TtscGraphMemory.js.map +1 -1
  10. package/lib/model/TtscGraphSession.js +92 -138
  11. package/lib/model/TtscGraphSession.js.map +1 -1
  12. package/lib/model/loadGraph.js +91 -138
  13. package/lib/model/loadGraph.js.map +1 -1
  14. package/lib/resolveGraphBinary.d.ts +4 -2
  15. package/lib/resolveGraphBinary.js +7 -3
  16. package/lib/resolveGraphBinary.js.map +1 -1
  17. package/lib/server/createServer.d.ts +16 -9
  18. package/lib/server/createServer.js +286 -190
  19. package/lib/server/createServer.js.map +1 -1
  20. package/lib/server/exportSurface.d.ts +26 -0
  21. package/lib/server/exportSurface.js +44 -0
  22. package/lib/server/exportSurface.js.map +1 -0
  23. package/lib/server/resolveHandle.d.ts +26 -1
  24. package/lib/server/resolveHandle.js +124 -4
  25. package/lib/server/resolveHandle.js.map +1 -1
  26. package/lib/server/resultAudit.d.ts +74 -0
  27. package/lib/server/resultAudit.js +110 -0
  28. package/lib/server/resultAudit.js.map +1 -0
  29. package/lib/server/resultNext.d.ts +9 -0
  30. package/lib/server/resultNext.js +11 -0
  31. package/lib/server/resultNext.js.map +1 -0
  32. package/lib/server/runDetails.d.ts +15 -3
  33. package/lib/server/runDetails.js +105 -23
  34. package/lib/server/runDetails.js.map +1 -1
  35. package/lib/server/runEntrypoints.d.ts +2 -1
  36. package/lib/server/runEntrypoints.js +17 -10
  37. package/lib/server/runEntrypoints.js.map +1 -1
  38. package/lib/server/runLookup.d.ts +2 -1
  39. package/lib/server/runLookup.js +21 -9
  40. package/lib/server/runLookup.js.map +1 -1
  41. package/lib/server/runOverview.d.ts +2 -1
  42. package/lib/server/runOverview.js +5 -4
  43. package/lib/server/runOverview.js.map +1 -1
  44. package/lib/server/runTour.d.ts +2 -1
  45. package/lib/server/runTour.js +707 -331
  46. package/lib/server/runTour.js.map +1 -1
  47. package/lib/server/runTrace.d.ts +2 -1
  48. package/lib/server/runTrace.js +234 -54
  49. package/lib/server/runTrace.js.map +1 -1
  50. package/lib/structures/ITtscGraphApplication.d.ts +122 -118
  51. package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
  52. package/lib/structures/ITtscGraphDetails.d.ts +51 -43
  53. package/lib/structures/ITtscGraphDump.d.ts +32 -8
  54. package/lib/structures/ITtscGraphEdge.d.ts +4 -6
  55. package/lib/structures/ITtscGraphEntrypoints.d.ts +10 -27
  56. package/lib/structures/ITtscGraphEscape.d.ts +6 -16
  57. package/lib/structures/ITtscGraphEvidence.d.ts +5 -8
  58. package/lib/structures/ITtscGraphLookup.d.ts +9 -20
  59. package/lib/structures/ITtscGraphNext.d.ts +10 -7
  60. package/lib/structures/ITtscGraphNode.d.ts +17 -8
  61. package/lib/structures/ITtscGraphOverview.d.ts +10 -14
  62. package/lib/structures/ITtscGraphSpan.d.ts +29 -0
  63. package/lib/structures/{ITtscGraphDiagnostic.js → ITtscGraphSpan.js} +1 -1
  64. package/lib/structures/ITtscGraphSpan.js.map +1 -0
  65. package/lib/structures/ITtscGraphTour.d.ts +65 -23
  66. package/lib/structures/ITtscGraphTrace.d.ts +72 -49
  67. package/lib/structures/TtscGraphEdgeKind.d.ts +7 -1
  68. package/lib/structures/index.d.ts +1 -1
  69. package/lib/structures/index.js +1 -1
  70. package/lib/structures/index.js.map +1 -1
  71. package/lib/view.js +3 -1
  72. package/lib/view.js.map +1 -1
  73. package/package.json +4 -4
  74. package/src/TtscGraphApplication.ts +58 -27
  75. package/src/index.ts +19 -1
  76. package/src/model/TtscGraphMemory.ts +86 -22
  77. package/src/model/TtscGraphSession.ts +5 -1
  78. package/src/model/loadGraph.ts +3 -1
  79. package/src/resolveGraphBinary.ts +7 -3
  80. package/src/server/createServer.ts +24 -17
  81. package/src/server/exportSurface.ts +40 -0
  82. package/src/server/resolveHandle.ts +141 -4
  83. package/src/server/resultAudit.ts +109 -0
  84. package/src/server/resultNext.ts +22 -0
  85. package/src/server/runDetails.ts +112 -28
  86. package/src/server/runEntrypoints.ts +26 -17
  87. package/src/server/runLookup.ts +29 -18
  88. package/src/server/runOverview.ts +9 -10
  89. package/src/server/runTour.ts +764 -363
  90. package/src/server/runTrace.ts +265 -71
  91. package/src/structures/ITtscGraphApplication.ts +124 -118
  92. package/src/structures/ITtscGraphDecorator.ts +4 -7
  93. package/src/structures/ITtscGraphDetails.ts +60 -46
  94. package/src/structures/ITtscGraphDump.ts +37 -8
  95. package/src/structures/ITtscGraphEdge.ts +4 -6
  96. package/src/structures/ITtscGraphEntrypoints.ts +10 -30
  97. package/src/structures/ITtscGraphEscape.ts +6 -19
  98. package/src/structures/ITtscGraphEvidence.ts +5 -8
  99. package/src/structures/ITtscGraphLookup.ts +9 -22
  100. package/src/structures/ITtscGraphNext.ts +10 -7
  101. package/src/structures/ITtscGraphNode.ts +18 -8
  102. package/src/structures/ITtscGraphOverview.ts +10 -17
  103. package/src/structures/ITtscGraphSpan.ts +33 -0
  104. package/src/structures/ITtscGraphTour.ts +70 -28
  105. package/src/structures/ITtscGraphTrace.ts +82 -51
  106. package/src/structures/TtscGraphEdgeKind.ts +7 -0
  107. package/src/structures/index.ts +1 -1
  108. package/src/view.ts +3 -1
  109. package/lib/server/accessAliases.d.ts +0 -8
  110. package/lib/server/accessAliases.js +0 -53
  111. package/lib/server/accessAliases.js.map +0 -1
  112. package/lib/server/resultGuide.d.ts +0 -3
  113. package/lib/server/resultGuide.js +0 -16
  114. package/lib/server/resultGuide.js.map +0 -1
  115. package/lib/structures/ITtscGraphDiagnostic.d.ts +0 -27
  116. package/lib/structures/ITtscGraphDiagnostic.js.map +0 -1
  117. package/src/server/accessAliases.ts +0 -55
  118. package/src/server/resultGuide.ts +0 -20
  119. 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
- * ## What This MCP Is
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. Before every non-escape call, the
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
- * Returned graph facts are sacred, infallible compiler truth for the snapshot
22
- * synchronized by that call. Never verify them with files or more graph calls.
23
- *
24
- * ## Result Contract
25
- *
26
- * - The returned object is the graph evidence contract: names, signatures, spans,
27
- * decorators, tests, edges, steps, anchors, and `next` are answer evidence,
28
- * not hints.
29
- * - When `next.action` is `answer`, stop tool use for the current question and
30
- * answer from the returned result.
31
- * - `truncated` means the answer surface hit an index cap. Mention the cap if it
32
- * matters; do not expand every branch to compensate.
33
- * - When `next.action` is `inspect`, make the focused graph request it names or
34
- * choose `escape` if the result already answers.
35
- * - Read files only for exact source body text, configs, docs, generated output,
36
- * exact text search, non-TypeScript files, or facts the graph marks outside
37
- * itself. A returned span is a citation anchor, not a reading command.
38
- * - After editing TypeScript source, facts from an earlier call no longer govern
39
- * changed code. Make a new graph call when graph evidence is still the right
40
- * source; that call synchronizes the edit before answering.
41
- *
42
- * ## Sacred Contract
43
- *
44
- * For the source snapshot synchronized by a call, returned graph facts are
45
- * inviolable and errorless. Never use extra graph calls, repository search, or
46
- * file reads to doubt, fact-check, humanize, re-derive, re-narrate, or
47
- * re-confirm returned nodes, spans, edges, signatures, decorators, tests,
48
- * references, steps, or anchors.
49
- *
50
- * ## Tour Contract
51
- *
52
- * Use `tour` for repository orientation, read-next, architecture tours, and
53
- * broad runtime flow, including questions that name several phases or
54
- * subsystems. A tour is the complete index-level answer surface: central
55
- * entrypoints, primary flow, nearby paths, tests, and anchors. Do not decompose
56
- * a broad tour into lookup/details loops unless the user later asks for a named
57
- * missing symbol or exact source text.
58
- *
59
- * ## Use Contract
60
- *
61
- * 1. Ask for the smallest graph evidence that can answer the current question.
62
- * 2. Broad flow, repository-orientation, code-tour, or read-next question: start
63
- * with `tour`.
64
- * 3. Concrete named symbol: use `lookup`, then `details` only if needed.
65
- * 4. Known endpoint pair or one selected handle: use one `trace`.
66
- * 5. Unknown narrow orientation: use `entrypoints` once.
67
- * 6. Selected symbol shape: use `details` for one to three handles.
68
- * 7. Follow the returned `next`: answer, inspect once more, leave graph, or
69
- * clarify.
70
- * 8. Use `escape` when another graph call would repeat evidence or the remaining
71
- * evidence is outside the TypeScript graph.
72
- *
73
- * Most TypeScript structure answers need one or two graph calls.
74
- *
75
- * ## Request Fields
76
- *
77
- * Fill the visible checklist, then exactly one request.
78
- *
79
- * - `question`: restate the code question being considered.
80
- * - `draft`: initial request type and why it seems smallest.
81
- * - `review`: correct a wrong, broad, stale, or duplicate draft. If graph facts
82
- * already answer, if prior `next.action` was `answer`, or if the next
83
- * evidence is outside the indexed TypeScript graph, say so here and make
84
- * `request.type` be `escape`. If a broad flow draft is not `tour`, correct it
85
- * here.
86
- * - `request`: final request after review.
87
- *
88
- * ## How to answer from graph evidence
89
- *
90
- * - Use returned node names, signatures, edges, references, evidence, and
91
- * `sourceSpan` ranges directly.
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
- * Inspect the TypeScript compiler graph contract.
94
+ * Answer a TypeScript question from the compiler's own index of this
95
+ * repository.
101
96
  *
102
- * Use this before repository search when an answer depends on TypeScript
103
- * symbols, calls, types, decorators, references, ranges, or runtime/source
104
- * relationships. For repository orientation, read-next, architecture, and
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
- * Returned nodes, edges, signatures, spans, tests, anchors, and `next` are
108
- * the answer surface. If `next.action` is `answer`, stop tool use and answer
109
- * from that result. Graph facts are sacred, inviolable, complete, and
110
- * infallible for the source snapshot synchronized by this call.
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.IResult>;
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
- * User's TypeScript code question.
127
+ * The code question, in the user's own words.
125
128
  *
126
- * Restate the code question being considered. If the next evidence is a
127
- * script, config, doc, generated output, exact text, non-TypeScript file,
128
- * or source body text, choose `escape`.
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
- * Final self-review before calling.
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 operation chosen after review, or a no-op escape. */
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 request type looks like the smallest useful next step. */
157
+ /** Why this is the smallest useful next step. */
171
158
  reason: string;
172
159
 
173
- /** The request type being considered, corrected later in `review`. */
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 IResult {
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
- * The graph reports the decorator faithfully rather than interpreting any
6
- * framework's convention: the `name` is the decorator as written (`Controller`,
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
- * The source-free facts for a few selected handles.
7
- *
8
- * This is not a file reader. It returns signatures, member outlines, direct
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
- /** How to use this source-free result next. */
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 from another tool, or dotted symbol handles such as
36
- * `OrderService.create`. Pass the few handles you need for source-free
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 (the symbols it
44
- * uses and the symbols that use it). The list is capped; raise
45
- * `neighborLimit` when the first slice is truncated and the missing
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 to return per side when
54
- * `neighbors:true`.
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 to return for a container or object literal. Raise
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 to return per group. Raise
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. Leave false for source-architecture answers; enable
84
- * only when external type/API boundaries are the question.
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
- * For a container or object-literal variable: the owned symbol or top-level
131
- * property outline a consumer reaches for, without bodies.
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 for the expression that produced this relationship. It is
185
- * repository evidence for the edge, not a file-read instruction.
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, and diagnostics are project-relative.
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: ITtscGraphNode[];
26
+ nodes: ITtscGraphDump.INode[];
27
27
 
28
28
  /** Every edge the build resolved. */
29
- edges: ITtscGraphEdge[];
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
- * Fused compiler and plugin diagnostics, when diagnostics were collected.
33
- * Absent when the dump was built without a diagnostics pass.
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
- diagnostics?: ITtscGraphDiagnostic[];
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 from one {@link ITtscGraphNode} to another, both named
6
- * by `id`. The triple `(from, to, kind)` is unique; a repeated relationship
7
- * keeps the first source-order evidence.
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. */