@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,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
- * ## What This MCP Is
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. Before every non-escape call, the
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
- * Returned graph facts are sacred, infallible compiler truth for the snapshot
21
- * synchronized by that call. Never verify them with files or more graph calls.
22
- *
23
- * ## Result Contract
24
- *
25
- * - The returned object is the graph evidence contract: names, signatures, spans,
26
- * decorators, tests, edges, steps, anchors, and `next` are answer evidence,
27
- * not hints.
28
- * - When `next.action` is `answer`, stop tool use for the current question and
29
- * answer from the returned result.
30
- * - `truncated` means the answer surface hit an index cap. Mention the cap if it
31
- * matters; do not expand every branch to compensate.
32
- * - When `next.action` is `inspect`, make the focused graph request it names or
33
- * choose `escape` if the result already answers.
34
- * - Read files only for exact source body text, configs, docs, generated output,
35
- * exact text search, non-TypeScript files, or facts the graph marks outside
36
- * itself. A returned span is a citation anchor, not a reading command.
37
- * - After editing TypeScript source, facts from an earlier call no longer govern
38
- * changed code. Make a new graph call when graph evidence is still the right
39
- * source; that call synchronizes the edit before answering.
40
- *
41
- * ## Sacred Contract
42
- *
43
- * For the source snapshot synchronized by a call, returned graph facts are
44
- * inviolable and errorless. Never use extra graph calls, repository search, or
45
- * file reads to doubt, fact-check, humanize, re-derive, re-narrate, or
46
- * re-confirm returned nodes, spans, edges, signatures, decorators, tests,
47
- * references, steps, or anchors.
48
- *
49
- * ## Tour Contract
50
- *
51
- * Use `tour` for repository orientation, read-next, architecture tours, and
52
- * broad runtime flow, including questions that name several phases or
53
- * subsystems. A tour is the complete index-level answer surface: central
54
- * entrypoints, primary flow, nearby paths, tests, and anchors. Do not decompose
55
- * a broad tour into lookup/details loops unless the user later asks for a named
56
- * missing symbol or exact source text.
57
- *
58
- * ## Use Contract
59
- *
60
- * 1. Ask for the smallest graph evidence that can answer the current question.
61
- * 2. Broad flow, repository-orientation, code-tour, or read-next question: start
62
- * with `tour`.
63
- * 3. Concrete named symbol: use `lookup`, then `details` only if needed.
64
- * 4. Known endpoint pair or one selected handle: use one `trace`.
65
- * 5. Unknown narrow orientation: use `entrypoints` once.
66
- * 6. Selected symbol shape: use `details` for one to three handles.
67
- * 7. Follow the returned `next`: answer, inspect once more, leave graph, or
68
- * clarify.
69
- * 8. Use `escape` when another graph call would repeat evidence or the remaining
70
- * evidence is outside the TypeScript graph.
71
- *
72
- * Most TypeScript structure answers need one or two graph calls.
73
- *
74
- * ## Request Fields
75
- *
76
- * Fill the visible checklist, then exactly one request.
77
- *
78
- * - `question`: restate the code question being considered.
79
- * - `draft`: initial request type and why it seems smallest.
80
- * - `review`: correct a wrong, broad, stale, or duplicate draft. If graph facts
81
- * already answer, if prior `next.action` was `answer`, or if the next
82
- * evidence is outside the indexed TypeScript graph, say so here and make
83
- * `request.type` be `escape`. If a broad flow draft is not `tour`, correct it
84
- * here.
85
- * - `request`: final request after review.
86
- *
87
- * ## How to answer from graph evidence
88
- *
89
- * - Use returned node names, signatures, edges, references, evidence, and
90
- * `sourceSpan` ranges directly.
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
- * Inspect the TypeScript compiler graph contract.
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
- * Use this before repository search when an answer depends on TypeScript
102
- * symbols, calls, types, decorators, references, ranges, or runtime/source
103
- * relationships. For repository orientation, read-next, architecture, and
104
- * broad runtime flow questions, use `tour`.
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
- * Returned nodes, edges, signatures, spans, tests, anchors, and `next` are
107
- * the answer surface. If `next.action` is `answer`, stop tool use and answer
108
- * from that result. Graph facts are sacred, inviolable, complete, and
109
- * infallible for the source snapshot synchronized by this call.
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.IResult>;
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
- * User's TypeScript code question.
123
+ * The code question, in the user's own words.
121
124
  *
122
- * Restate the code question being considered. If the next evidence is a
123
- * script, config, doc, generated output, exact text, non-TypeScript file,
124
- * or source body text, choose `escape`.
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
- * Final self-review before calling.
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 operation chosen after review, or a no-op escape. */
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 request type looks like the smallest useful next step. */
142
+ /** Why this is the smallest useful next step. */
156
143
  reason: string;
157
- /** The request type being considered, corrected later in `review`. */
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 IResult {
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
- * 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,24 +1,27 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
2
  import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
3
- import { ITtscGraphNext } from "./ITtscGraphNext";
4
3
  /**
5
- * The source-free facts for a few selected handles.
6
- *
7
- * This is not a file reader. It returns signatures, member outlines, direct
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
- /** How to use this source-free result next. */
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 from another tool, or dotted symbol handles such as
30
- * `OrderService.create`. Pass the few handles you need for source-free
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 (the symbols it
37
- * uses and the symbols that use it). The list is capped; raise
38
- * `neighborLimit` when the first slice is truncated and the missing
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 to return per side when
46
- * `neighbors:true`.
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 to return for a container or object literal. Raise
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 to return per group. Raise
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. Leave false for source-architecture answers; enable
73
- * only when external type/API boundaries are the question.
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
- * For a container or object-literal variable: the owned symbol or top-level
107
- * property outline a consumer reaches for, without bodies.
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 for the expression that produced this relationship. It is
146
- * repository evidence for the edge, not a file-read instruction.
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, and diagnostics are project-relative.
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: ITtscGraphNode[];
23
+ nodes: ITtscGraphDump.INode[];
24
24
  /** Every edge the build resolved. */
25
- edges: ITtscGraphEdge[];
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
- * Fused compiler and plugin diagnostics, when diagnostics were collected.
28
- * Absent when the dump was built without a diagnostics pass.
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
- diagnostics?: ITtscGraphDiagnostic[];
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 from one {@link ITtscGraphNode} to another, both named
5
- * by `id`. The triple `(from, to, kind)` is unique; a repeated relationship
6
- * keeps the first source-order evidence.
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
- /** How to use this source-free result next. */
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
- * Ask for first handles when the question is narrow but the symbol is not yet
26
- * known. For broad tours, read-next, architecture, or multi-phase runtime
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. Mix prose with code handles,
35
- * for example `how Repository.find loads relations` or
36
- * `SelectQueryBuilder.setFindOptions join aliases`. Keep this close to the
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 to return per indexed symbol.
51
- * This is an orientation slice, not a dependency dump; use `trace` or
52
- * `details` with `neighbors:true` after choosing the specific handles.
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
  }