@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.
Files changed (125) hide show
  1. package/README.md +231 -36
  2. package/lib/TtscGraphApplication.d.ts +4 -3
  3. package/lib/TtscGraphApplication.js +54 -19
  4. package/lib/TtscGraphApplication.js.map +1 -1
  5. package/lib/index.d.ts +9 -4
  6. package/lib/index.js +24 -5
  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.d.ts +36 -0
  11. package/lib/model/TtscGraphSession.js +457 -0
  12. package/lib/model/TtscGraphSession.js.map +1 -0
  13. package/lib/model/loadGraph.d.ts +3 -3
  14. package/lib/model/loadGraph.js +94 -141
  15. package/lib/model/loadGraph.js.map +1 -1
  16. package/lib/resolveGraphBinary.d.ts +4 -2
  17. package/lib/resolveGraphBinary.js +7 -3
  18. package/lib/resolveGraphBinary.js.map +1 -1
  19. package/lib/server/createServer.d.ts +16 -9
  20. package/lib/server/createServer.js +286 -190
  21. package/lib/server/createServer.js.map +1 -1
  22. package/lib/server/exportSurface.d.ts +26 -0
  23. package/lib/server/exportSurface.js +44 -0
  24. package/lib/server/exportSurface.js.map +1 -0
  25. package/lib/server/resolveHandle.d.ts +26 -1
  26. package/lib/server/resolveHandle.js +124 -4
  27. package/lib/server/resolveHandle.js.map +1 -1
  28. package/lib/server/resultAudit.d.ts +74 -0
  29. package/lib/server/resultAudit.js +110 -0
  30. package/lib/server/resultAudit.js.map +1 -0
  31. package/lib/server/resultNext.d.ts +9 -0
  32. package/lib/server/resultNext.js +11 -0
  33. package/lib/server/resultNext.js.map +1 -0
  34. package/lib/server/runDetails.d.ts +15 -3
  35. package/lib/server/runDetails.js +105 -23
  36. package/lib/server/runDetails.js.map +1 -1
  37. package/lib/server/runEntrypoints.d.ts +2 -1
  38. package/lib/server/runEntrypoints.js +17 -10
  39. package/lib/server/runEntrypoints.js.map +1 -1
  40. package/lib/server/runLookup.d.ts +2 -1
  41. package/lib/server/runLookup.js +21 -9
  42. package/lib/server/runLookup.js.map +1 -1
  43. package/lib/server/runOverview.d.ts +2 -1
  44. package/lib/server/runOverview.js +5 -4
  45. package/lib/server/runOverview.js.map +1 -1
  46. package/lib/server/runTour.d.ts +2 -1
  47. package/lib/server/runTour.js +707 -331
  48. package/lib/server/runTour.js.map +1 -1
  49. package/lib/server/runTrace.d.ts +2 -1
  50. package/lib/server/runTrace.js +234 -54
  51. package/lib/server/runTrace.js.map +1 -1
  52. package/lib/server/startServer.d.ts +3 -2
  53. package/lib/server/startServer.js +13 -7
  54. package/lib/server/startServer.js.map +1 -1
  55. package/lib/structures/ITtscGraphApplication.d.ts +122 -114
  56. package/lib/structures/ITtscGraphDecorator.d.ts +4 -7
  57. package/lib/structures/ITtscGraphDetails.d.ts +51 -43
  58. package/lib/structures/ITtscGraphDump.d.ts +36 -11
  59. package/lib/structures/ITtscGraphEdge.d.ts +4 -6
  60. package/lib/structures/ITtscGraphEntrypoints.d.ts +10 -27
  61. package/lib/structures/ITtscGraphEscape.d.ts +6 -16
  62. package/lib/structures/ITtscGraphEvidence.d.ts +5 -8
  63. package/lib/structures/ITtscGraphLookup.d.ts +9 -20
  64. package/lib/structures/ITtscGraphNext.d.ts +10 -7
  65. package/lib/structures/ITtscGraphNode.d.ts +17 -8
  66. package/lib/structures/ITtscGraphOverview.d.ts +10 -14
  67. package/lib/structures/ITtscGraphSpan.d.ts +29 -0
  68. package/lib/structures/{ITtscGraphDiagnostic.js → ITtscGraphSpan.js} +1 -1
  69. package/lib/structures/ITtscGraphSpan.js.map +1 -0
  70. package/lib/structures/ITtscGraphTour.d.ts +65 -23
  71. package/lib/structures/ITtscGraphTrace.d.ts +72 -49
  72. package/lib/structures/TtscGraphEdgeKind.d.ts +7 -1
  73. package/lib/structures/index.d.ts +1 -1
  74. package/lib/structures/index.js +1 -1
  75. package/lib/structures/index.js.map +1 -1
  76. package/lib/view.js +3 -1
  77. package/lib/view.js.map +1 -1
  78. package/package.json +4 -4
  79. package/src/TtscGraphApplication.ts +66 -31
  80. package/src/index.ts +23 -5
  81. package/src/model/TtscGraphMemory.ts +86 -22
  82. package/src/model/TtscGraphSession.ts +204 -0
  83. package/src/model/loadGraph.ts +6 -4
  84. package/src/resolveGraphBinary.ts +7 -3
  85. package/src/server/createServer.ts +24 -17
  86. package/src/server/exportSurface.ts +40 -0
  87. package/src/server/resolveHandle.ts +141 -4
  88. package/src/server/resultAudit.ts +109 -0
  89. package/src/server/resultNext.ts +22 -0
  90. package/src/server/runDetails.ts +112 -28
  91. package/src/server/runEntrypoints.ts +26 -17
  92. package/src/server/runLookup.ts +29 -18
  93. package/src/server/runOverview.ts +9 -10
  94. package/src/server/runTour.ts +764 -363
  95. package/src/server/runTrace.ts +265 -71
  96. package/src/server/startServer.ts +13 -8
  97. package/src/structures/ITtscGraphApplication.ts +124 -114
  98. package/src/structures/ITtscGraphDecorator.ts +4 -7
  99. package/src/structures/ITtscGraphDetails.ts +60 -46
  100. package/src/structures/ITtscGraphDump.ts +41 -11
  101. package/src/structures/ITtscGraphEdge.ts +4 -6
  102. package/src/structures/ITtscGraphEntrypoints.ts +10 -30
  103. package/src/structures/ITtscGraphEscape.ts +6 -19
  104. package/src/structures/ITtscGraphEvidence.ts +5 -8
  105. package/src/structures/ITtscGraphLookup.ts +9 -22
  106. package/src/structures/ITtscGraphNext.ts +10 -7
  107. package/src/structures/ITtscGraphNode.ts +18 -8
  108. package/src/structures/ITtscGraphOverview.ts +10 -17
  109. package/src/structures/ITtscGraphSpan.ts +33 -0
  110. package/src/structures/ITtscGraphTour.ts +70 -28
  111. package/src/structures/ITtscGraphTrace.ts +82 -51
  112. package/src/structures/TtscGraphEdgeKind.ts +7 -0
  113. package/src/structures/index.ts +1 -1
  114. package/src/view.ts +3 -1
  115. package/lib/server/accessAliases.d.ts +0 -8
  116. package/lib/server/accessAliases.js +0 -53
  117. package/lib/server/accessAliases.js.map +0 -1
  118. package/lib/server/resultGuide.d.ts +0 -3
  119. package/lib/server/resultGuide.js +0 -16
  120. package/lib/server/resultGuide.js.map +0 -1
  121. package/lib/structures/ITtscGraphDiagnostic.d.ts +0 -27
  122. package/lib/structures/ITtscGraphDiagnostic.js.map +0 -1
  123. package/src/server/accessAliases.ts +0 -55
  124. package/src/server/resultGuide.ts +0 -20
  125. package/src/structures/ITtscGraphDiagnostic.ts +0 -34
@@ -1,15 +1,11 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
2
  import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
3
- import { ITtscGraphNext } from "./ITtscGraphNext";
4
3
 
5
4
  /** The first compact source-free handle list for a TypeScript code question. */
6
5
  export interface ITtscGraphEntrypoints {
7
6
  /** Discriminator for first-pass question indexing. */
8
7
  type: "entrypoints";
9
8
 
10
- /** The original question/search phrase the entrypoints were built for. */
11
- query: string;
12
-
13
9
  /** Ranked symbols relevant to the query. */
14
10
  hits: ITtscGraphEntrypoints.IHit[];
15
11
 
@@ -19,50 +15,37 @@ export interface ITtscGraphEntrypoints {
19
15
  /** Direct dependency context for the resolved mentions and highest hits. */
20
16
  neighborhood: ITtscGraphEntrypoints.INeighborhood[];
21
17
 
22
- /** How to use this source-free result next. */
23
- next: ITtscGraphNext;
24
-
25
- /** Human-readable compatibility note mirroring `next`. */
26
- guide: string;
27
-
28
- /** True when result caps hid additional seeds or references. */
18
+ /** True when some low-signal seeds or references were capped; the list stands. */
29
19
  truncated?: boolean;
30
20
  }
31
21
 
32
22
  export namespace ITtscGraphEntrypoints {
33
23
  /**
34
- * Ask for first handles when the question is narrow but the symbol is not yet
35
- * known. For broad tours, read-next, architecture, or multi-phase runtime
36
- * flow, use `tour` instead of decomposing the answer into entrypoints and
37
- * follow-up calls.
24
+ * First handles when the question is narrow but the symbol name is not yet
25
+ * known.
38
26
  */
39
27
  export interface IRequest {
40
28
  /** Discriminator for first-pass question indexing. */
41
29
  type: "entrypoints";
42
30
 
43
31
  /**
44
- * A natural code question or search phrase. Mix prose with code handles,
45
- * for example `how Repository.find loads relations` or
46
- * `SelectQueryBuilder.setFindOptions join aliases`. Keep this close to the
47
- * user's question; do not turn it into a broad keyword dump.
32
+ * A natural code question or search phrase, prose mixed with code handles
33
+ * (`how Repository.find loads relations`). Keep it close to the user's
34
+ * question, not a broad keyword dump.
48
35
  */
49
36
  query: string;
50
37
 
51
38
  /**
52
39
  * Maximum ranked hits to return.
53
40
  *
54
- * Prefer the default. Raise only when the first result was truncated and
55
- * the missing handle is named.
56
- *
57
41
  * @default 4
58
42
  */
59
43
  limit?: number;
60
44
 
61
45
  /**
62
- * Maximum direct dependencies and dependents to return per indexed symbol.
63
- * This is an orientation slice, not a dependency dump; use `trace` or
64
- * `details` with `neighbors:true` after choosing the specific handles.
65
- * Prefer the default zero for the first call.
46
+ * Maximum direct dependencies and dependents per indexed symbol. An
47
+ * orientation slice, not a dependency dump; use `trace` or `details` with
48
+ * `neighbors:true` after choosing the specific handles.
66
49
  *
67
50
  * @default 0
68
51
  */
@@ -140,10 +123,7 @@ export namespace ITtscGraphEntrypoints {
140
123
  /** Edge kind connecting the indexed node and this neighbor. */
141
124
  relation: string;
142
125
 
143
- /**
144
- * Source span for the expression that produced this relationship. It lets
145
- * an agent see why the edge exists without opening the file.
146
- */
126
+ /** Source span for the edge: shows why it exists without opening the file. */
147
127
  evidence?: ITtscGraphEvidence;
148
128
  }
149
129
  }
@@ -1,5 +1,3 @@
1
- import { ITtscGraphNext } from "./ITtscGraphNext";
2
-
3
1
  /** The no-op result for when graph is not the useful next evidence source. */
4
2
  export interface ITtscGraphEscape {
5
3
  /** Discriminator for the no-op escape route. */
@@ -11,12 +9,6 @@ export interface ITtscGraphEscape {
11
9
  /** Why no graph operation should run. */
12
10
  reason: string;
13
11
 
14
- /** How to proceed after skipping graph work. */
15
- next: ITtscGraphNext;
16
-
17
- /** Human-readable compatibility note mirroring `next`. */
18
- guide: string;
19
-
20
12
  /** Optional note about the next non-graph step. */
21
13
  nextStep?: string;
22
14
  }
@@ -28,21 +20,16 @@ export namespace ITtscGraphEscape {
28
20
  type: "escape";
29
21
 
30
22
  /**
31
- * Why no graph operation should run.
32
- *
33
- * Use this only when the next evidence is outside the indexed TypeScript
34
- * graph: package scripts, config files, generated output, prose docs, exact
35
- * text, or exact source body text. Name the smallest returned sourceSpan
36
- * when source body text is truly required.
23
+ * Why no graph operation should run. Use only when the next evidence is
24
+ * outside the indexed graph: package scripts, config files, generated
25
+ * output, prose docs, exact text, or source body text. Name the smallest
26
+ * returned sourceSpan when source body text is truly required.
37
27
  */
38
28
  reason: string;
39
29
 
40
30
  /**
41
- * The final non-graph note, if useful.
42
- *
43
- * Keep this short. Examples: `answer from the prior graph result`, `source
44
- * body needed at returned sourceSpan`, or `ask the user for a concrete
45
- * symbol`.
31
+ * A short final non-graph note, if useful, for example `answer from the
32
+ * prior graph result` or `source body needed at returned sourceSpan`.
46
33
  */
47
34
  nextStep?: string;
48
35
  }
@@ -1,12 +1,9 @@
1
1
  /**
2
- * A source location that grounds a node or edge in real code: the declaration
3
- * span for a node, or the expression range that produced an edge.
4
- *
5
- * Evidence is display and grounding only; it is never identity. A node's id is
6
- * position-invariant (see {@link ITtscGraphNode}), so an edit that shifts a span
7
- * does not re-key anything. `startLine`/`startCol` are 1-based. MCP output
8
- * keeps evidence as coordinates; consumers can read the file themselves when
9
- * they truly need source text.
2
+ * A source location grounding a node or edge in real code: the declaration span
3
+ * for a node, or the expression range that produced an edge. Display and
4
+ * grounding only, never identity (a node's id is position-invariant, see
5
+ * {@link ITtscGraphNode}). Lines and columns are 1-based; MCP keeps evidence as
6
+ * coordinates, so read the file yourself when you truly need source text.
10
7
  */
11
8
  export interface ITtscGraphEvidence {
12
9
  /** Project-relative path of the file the span lives in. */
@@ -1,5 +1,4 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
- import { ITtscGraphNext } from "./ITtscGraphNext";
3
2
 
4
3
  /** Targeted symbol lookup when a concrete name or handle is being resolved. */
5
4
  export interface ITtscGraphLookup {
@@ -8,12 +7,6 @@ export interface ITtscGraphLookup {
8
7
 
9
8
  /** Ranked symbol matches for the query. */
10
9
  hits: ITtscGraphLookup.IHit[];
11
-
12
- /** How to use this source-free result next. */
13
- next: ITtscGraphNext;
14
-
15
- /** Human-readable compatibility note mirroring `next`. */
16
- guide: string;
17
10
  }
18
11
  export namespace ITtscGraphLookup {
19
12
  /** Find a concrete class, method, function, property, type, or dotted handle. */
@@ -22,19 +15,16 @@ export namespace ITtscGraphLookup {
22
15
  type: "lookup";
23
16
 
24
17
  /**
25
- * What to find, in natural language and code vocabulary mixed freely: a
26
- * symbol name, a dotted member (`Service.create`), or a short phrase
27
- * (`request handler`). Exact names are not required, but this is not a
28
- * second broad entrypoints call. Use it when a named handle is missing or
29
- * ambiguous.
18
+ * What to find: a symbol name, a dotted member (`Service.create`), or a
19
+ * short phrase (`request handler`). Exact names are not required, but this
20
+ * is not a second broad entrypoints call; use it for a missing or ambiguous
21
+ * named handle.
30
22
  */
31
23
  query: string;
32
24
 
33
25
  /**
34
- * Maximum hits to return.
35
- *
36
- * Prefer the default. Large hit lists usually mean the query is too broad;
37
- * refine the name instead of raising this.
26
+ * Maximum hits to return. A large hit list usually means the query is too
27
+ * broad; refine the name instead of raising this.
38
28
  *
39
29
  * @default 5
40
30
  */
@@ -42,8 +32,8 @@ export namespace ITtscGraphLookup {
42
32
 
43
33
  /**
44
34
  * Include dependency-boundary declarations from node_modules or bundled
45
- * `.d.ts` libraries. Leave false for project-source answers; enable only
46
- * when external type/API boundaries are the question.
35
+ * `.d.ts` libraries. Enable only when external type/API boundaries are the
36
+ * question.
47
37
  *
48
38
  * @default false
49
39
  */
@@ -67,10 +57,7 @@ export namespace ITtscGraphLookup {
67
57
  /** 1-based declaration line, when known. */
68
58
  line?: number;
69
59
 
70
- /**
71
- * The hit's declaration signature, so you can often answer without
72
- * requesting details.
73
- */
60
+ /** Declaration signature, often enough to answer without a `details` call. */
74
61
  signature?: string;
75
62
 
76
63
  /** Decorators written on this declaration, when any. */
@@ -1,15 +1,18 @@
1
- /** The required next step from a compiler-derived graph result. */
1
+ /** What to do with a compiler-derived graph result. */
2
2
  export interface ITtscGraphNext {
3
3
  /**
4
- * Answer, continue graph inspection, leave graph, or clarify.
4
+ * What to do with this result:
5
5
  *
6
- * `answer` means the returned graph result already carries the evidence
7
- * contract for the current question, even when the slice is capped. Do not
8
- * call graph again or read files to re-check or complete it.
6
+ * - `answer`: the result carries the evidence; stop and answer, do not call
7
+ * graph again or read files to re-check it
8
+ * - `inspect`: the result is genuinely partial; make exactly the one `request`
9
+ * named, once
10
+ * - `outside`: the answer is outside the graph; escape and read source
11
+ * - `clarify`: the request was malformed or ambiguous; restate it
9
12
  */
10
13
  action: "answer" | "inspect" | "outside" | "clarify";
11
14
 
12
- /** Smallest graph request type to use when `action` is `inspect`. */
15
+ /** The single graph request type to use when `action` is `inspect`. */
13
16
  request?:
14
17
  | "entrypoints"
15
18
  | "lookup"
@@ -18,6 +21,6 @@ export interface ITtscGraphNext {
18
21
  | "overview"
19
22
  | "tour";
20
23
 
21
- /** Why the returned graph evidence supports that action. */
24
+ /** Why the returned evidence supports that action. */
22
25
  reason: string;
23
26
  }
@@ -33,15 +33,14 @@ export interface ITtscGraphNode {
33
33
  file: string;
34
34
 
35
35
  /**
36
- * True when the declaration lives outside the workspace (a dependency). The
37
- * graph keeps the leaf as a named endpoint but does not walk into its
38
- * internals.
36
+ * True when the declaration is outside the workspace (a dependency): kept as
37
+ * a named endpoint, not walked into.
39
38
  */
40
39
  external: boolean;
41
40
 
42
41
  /**
43
- * True when `file` is git-ignored generated code (a Prisma client, a codegen
44
- * output). Projections desurface these so generated nodes do not bury the
42
+ * True when `file` is git-ignored generated code (Prisma client, codegen
43
+ * output); projections desurface these so generated nodes do not bury the
45
44
  * authored graph.
46
45
  */
47
46
  ignored?: boolean;
@@ -49,13 +48,24 @@ export interface ITtscGraphNode {
49
48
  /** True when the symbol is part of its module's export surface. */
50
49
  exported?: boolean;
51
50
 
51
+ /**
52
+ * True for a declaration made inside another declaration's body: Vue's
53
+ * `baseCreateRenderer.patch`, a callback bound to a const inside a method.
54
+ *
55
+ * It is a name the runtime calls, so a trace, a lookup, or a details request
56
+ * answers with it. An orientation tour does not rank or walk it: a tour is
57
+ * asked what the project's surface is and how it runs, and a body's inner
58
+ * functions are neither — letting them into the seed ranking reshuffled which
59
+ * flows a tour told, and the model went back to the files.
60
+ */
61
+ closure?: boolean;
62
+
52
63
  /** Declaration modifiers, when the declaration pass recorded any. */
53
64
  modifiers?: TtscGraphNodeModifier[];
54
65
 
55
66
  /**
56
- * The decorators written on this declaration, in source order, when it has
57
- * any: raw decorator facts (`@Controller`, `@Get`) a consumer can interpret
58
- * without re-parsing source.
67
+ * Decorators written on this declaration, in source order: raw facts
68
+ * (`@Controller`, `@Get`) a consumer interprets without re-parsing source.
59
69
  */
60
70
  decorators?: ITtscGraphDecorator[];
61
71
 
@@ -1,5 +1,3 @@
1
- import { ITtscGraphNext } from "./ITtscGraphNext";
2
-
3
1
  /** A compact, source-read-free project map for broad orientation only. */
4
2
  export interface ITtscGraphOverview {
5
3
  /** Discriminator for source-free project overview. */
@@ -11,12 +9,6 @@ export interface ITtscGraphOverview {
11
9
  /** Size of the graph. */
12
10
  counts: ITtscGraphOverview.ICounts;
13
11
 
14
- /** How to use this source-free result next. */
15
- next: ITtscGraphNext;
16
-
17
- /** Human-readable compatibility note mirroring `next`. */
18
- guide: string;
19
-
20
12
  /** Folder layering, largest first. */
21
13
  layers?: ITtscGraphOverview.ILayer[];
22
14
 
@@ -33,13 +25,15 @@ export namespace ITtscGraphOverview {
33
25
  type: "overview";
34
26
 
35
27
  /**
36
- * The facet to project, or `all` for every facet. `layers` is the folder
37
- * layering, `hotspots` the highest-dependency symbols, `publicApi` the
38
- * exported API symbols ranked by how depended-on they are.
28
+ * Facet to project, or `all` for every facet:
29
+ *
30
+ * - `layers`: folder layering
31
+ * - `hotspots`: highest-dependency symbols
32
+ * - `publicApi`: exported API symbols ranked by how depended-on they are
39
33
  *
40
- * Use this only for broad public API or layer orientation. For behavior,
41
- * lifecycle, request-flow, rendering-flow, validation-flow, caller, or
42
- * dependency questions, use `entrypoints` then `trace` instead.
34
+ * Broad public-API or layer orientation only. For behavior, lifecycle,
35
+ * request/render/validation flow, caller, or dependency questions, use
36
+ * `entrypoints` then `trace`.
43
37
  *
44
38
  * @default "all"
45
39
  */
@@ -94,9 +88,8 @@ export namespace ITtscGraphOverview {
94
88
  }
95
89
 
96
90
  /**
97
- * One symbol on the project's exported public API surface. The list is ranked
98
- * by how depended-on the symbol is, with test, typings, and generated files
99
- * excluded.
91
+ * One exported public-API symbol. The list is ranked by how depended-on the
92
+ * symbol is, excluding test, typings, and generated files.
100
93
  */
101
94
  export type IPublicApi = INode;
102
95
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A span on the wire, without the file it lives in.
3
+ *
4
+ * The reader already knows the file: a node's span is in the node's `file`, and
5
+ * an edge's span is in the file its `from` id names. Sending the path a second
6
+ * and a third time cost 17% of the document — on VS Code, 55 MB of a 323 MB
7
+ * dump that then has to be encoded, piped, parsed and validated — for a value
8
+ * that is reconstructible exactly.
9
+ *
10
+ * {@link TtscGraphMemory} puts the file back before any of it is read, so what
11
+ * the graph engine and the MCP results see is the whole
12
+ * {@link ITtscGraphEvidence}. This shape exists only between the Go builder and
13
+ * the loader.
14
+ */
15
+ export interface ITtscGraphSpan {
16
+ /**
17
+ * Present only when it cannot be derived: an `implementation` can live in a
18
+ * different file from the declaration that owns it.
19
+ */
20
+ file?: string;
21
+
22
+ /** 1-based line where the span starts. */
23
+ startLine: number;
24
+
25
+ /** 1-based column where the span starts, when known. */
26
+ startCol?: number;
27
+
28
+ /** 1-based line where the span ends, when known. */
29
+ endLine?: number;
30
+
31
+ /** 1-based column where the span ends, when known. */
32
+ endCol?: number;
33
+ }
@@ -1,14 +1,10 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
- import { ITtscGraphNext } from "./ITtscGraphNext";
3
2
 
4
3
  /** Answer-ready, source-free tour evidence for broad code-flow questions. */
5
4
  export interface ITtscGraphTour {
6
5
  /** Discriminator for code-tour indexing. */
7
6
  type: "tour";
8
7
 
9
- /** Natural code question this tour was built for. */
10
- query: string;
11
-
12
8
  /** Central entrypoints selected for the tour. */
13
9
  entrypoints: ITtscGraphTour.INode[];
14
10
 
@@ -24,36 +20,51 @@ export interface ITtscGraphTour {
24
20
  /** Ordered file/line anchors to cite in the final answer, not file reads. */
25
21
  answerAnchors: ITtscGraphTour.IAnchor[];
26
22
 
27
- /** How to use this source-free result next. */
28
- next: ITtscGraphNext;
29
-
30
- /** Human-readable compatibility note mirroring `next`. */
31
- guide: string;
32
-
33
- /** True when any internal slice hit its cap. */
23
+ /** True when some low-signal extras were capped; the returned tour stands. */
34
24
  truncated?: boolean;
35
25
  }
36
26
 
37
27
  export namespace ITtscGraphTour {
38
28
  /**
39
- * Build the complete index-level answer surface for broad code tours: central
40
- * entrypoints, primary flow, nearby paths, tests, and answer anchors. Use
41
- * this instead of decomposing repository-orientation, read-next,
42
- * architecture, or multi-phase runtime-flow questions into many
43
- * lookup/details/trace calls.
29
+ * A broad code tour: entrypoints, primary flow, nearby paths, and tests.
30
+ *
31
+ * It asks for no question of its own — it ranks against the `question` the
32
+ * caller has already written, in the user's words.
44
33
  */
45
34
  export interface IRequest {
46
35
  /** Discriminator for code-tour indexing. */
47
36
  type: "tour";
48
37
 
49
- /** The user's natural code-tour question. */
50
- query: string;
51
-
52
38
  /**
53
- * Maximum central entrypoints to seed the tour.
39
+ * Symbol names, never a sentence: the machinery you expect the answer to be
40
+ * made of, spelled the way this codebase would spell it. A question about
41
+ * how a job reaches a worker is reinterpreted as `["JobQueue.push",
42
+ * "Scheduler.tick", "Worker.run", "drainQueue"]`.
54
43
  *
55
- * Prefer the default. Raise only when the question names several distinct
56
- * public paths that must all appear in one answer.
44
+ * Write them from the question, before you have seen a line of the code. A
45
+ * codebase names many things alike, and the question's own words cannot
46
+ * tell them apart: a question about _tracking_ matches the debug hook named
47
+ * after tracking as readily as the function that does it, and one about a
48
+ * _request_ matches a message listener as readily as an HTTP router. The
49
+ * names say which you meant.
50
+ *
51
+ * Each is resolved like a handle — a symbol name, a `Class.member`. The
52
+ * ones the graph holds take half the tour's entrypoints, the rest stays
53
+ * with what the graph finds central, and a name it does not know, or knows
54
+ * several of, is dropped. So a wrong guess costs nothing, and a specific
55
+ * name is worth more than a general one: `drainQueue` resolves, `queue`
56
+ * does not.
57
+ *
58
+ * Send `[]` when the question names no machinery — "show me the central
59
+ * flow" in a repository you have never seen. There is nothing to
60
+ * reinterpret then: the tour ranks on structure, which is what that
61
+ * question asks for. Do not look names up first to fill this.
62
+ */
63
+ reinterpretations: string[];
64
+
65
+ /**
66
+ * Central entrypoints to seed the tour. Raise only when the question names
67
+ * several public paths that must all appear in one answer.
57
68
  *
58
69
  * @default 4
59
70
  */
@@ -90,6 +101,13 @@ export namespace ITtscGraphTour {
90
101
  /** Declaration head, when available. */
91
102
  signature?: string;
92
103
 
104
+ /**
105
+ * The first sentence of the doc comment above the declaration: what the
106
+ * project says this symbol is for. A name and an edge say what calls what;
107
+ * this says why, which is what a tour is asked for.
108
+ */
109
+ doc?: string;
110
+
93
111
  /** Decorators written on the declaration, when any. */
94
112
  decorators?: ITtscGraphDecorator[];
95
113
  }
@@ -102,16 +120,40 @@ export namespace ITtscGraphTour {
102
120
  /** Compact edge summaries in graph order. */
103
121
  steps: string[];
104
122
 
105
- /** Nodes reached by this flow. */
106
- reached: ITtscGraphTour.INode[];
107
-
108
- /** Edge and node anchors that explain the flow. */
109
- anchors: ITtscGraphTour.IAnchor[];
123
+ /**
124
+ * Every node this flow reached, with the handle to call the graph with
125
+ * next.
126
+ *
127
+ * A step is prose — it names both of its ends and the file and line the
128
+ * call sits on — and it carries no handle. So the nodes a step names are
129
+ * listed here too: `steps` is the story, `reached` is what to go on with.
130
+ */
131
+ reached: ITtscGraphTour.IReached[];
110
132
 
111
- /** True when the flow hit graph caps. */
133
+ /** True when some low-signal flow steps were capped; the flow stands. */
112
134
  truncated?: boolean;
113
135
  }
114
136
 
137
+ /**
138
+ * A node a flow reached, as its handle and its declaration line.
139
+ *
140
+ * A node id _is_ its coordinates — `path/to/file.ts#Owner.member:kind` — so a
141
+ * reached node carrying `file` and `kind` beside it bought the same fact
142
+ * three times. Across the benchmark corpus that repetition was 15% of every
143
+ * tour, and a tour is re-sent whole on every turn of the conversation it
144
+ * opened.
145
+ */
146
+ export interface IReached {
147
+ /** Stable node id for later graph calls: `file#Qualified.Name:kind`. */
148
+ id: string;
149
+
150
+ /** Qualified symbol name when available, otherwise the simple name. */
151
+ name: string;
152
+
153
+ /** 1-based declaration line, when known. */
154
+ line?: number;
155
+ }
156
+
115
157
  /** A file/line citation chosen by the graph, not source body text. */
116
158
  export interface IAnchor {
117
159
  /** Why this anchor matters in the tour. */