@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
@@ -1,4 +1,3 @@
1
- import { ITtscGraphNext } from "./ITtscGraphNext";
2
1
  /** The no-op result for when graph is not the useful next evidence source. */
3
2
  export interface ITtscGraphEscape {
4
3
  /** Discriminator for the no-op escape route. */
@@ -7,10 +6,6 @@ export interface ITtscGraphEscape {
7
6
  skipped: true;
8
7
  /** Why no graph operation should run. */
9
8
  reason: string;
10
- /** How to proceed after skipping graph work. */
11
- next: ITtscGraphNext;
12
- /** Human-readable compatibility note mirroring `next`. */
13
- guide: string;
14
9
  /** Optional note about the next non-graph step. */
15
10
  nextStep?: string;
16
11
  }
@@ -20,20 +15,15 @@ export declare namespace ITtscGraphEscape {
20
15
  /** Discriminator for the no-op escape route. */
21
16
  type: "escape";
22
17
  /**
23
- * Why no graph operation should run.
24
- *
25
- * Use this only when the next evidence is outside the indexed TypeScript
26
- * graph: package scripts, config files, generated output, prose docs, exact
27
- * text, or exact source body text. Name the smallest returned sourceSpan
28
- * when source body text is truly required.
18
+ * Why no graph operation should run. Use only when the next evidence is
19
+ * outside the indexed graph: package scripts, config files, generated
20
+ * output, prose docs, exact text, or source body text. Name the smallest
21
+ * returned sourceSpan when source body text is truly required.
29
22
  */
30
23
  reason: string;
31
24
  /**
32
- * The final non-graph note, if useful.
33
- *
34
- * Keep this short. Examples: `answer from the prior graph result`, `source
35
- * body needed at returned sourceSpan`, or `ask the user for a concrete
36
- * symbol`.
25
+ * A short final non-graph note, if useful, for example `answer from the
26
+ * prior graph result` or `source body needed at returned sourceSpan`.
37
27
  */
38
28
  nextStep?: string;
39
29
  }
@@ -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,15 +1,10 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
- import { ITtscGraphNext } from "./ITtscGraphNext";
3
2
  /** Targeted symbol lookup when a concrete name or handle is being resolved. */
4
3
  export interface ITtscGraphLookup {
5
4
  /** Discriminator for targeted symbol lookup. */
6
5
  type: "lookup";
7
6
  /** Ranked symbol matches for the query. */
8
7
  hits: ITtscGraphLookup.IHit[];
9
- /** How to use this source-free result next. */
10
- next: ITtscGraphNext;
11
- /** Human-readable compatibility note mirroring `next`. */
12
- guide: string;
13
8
  }
14
9
  export declare namespace ITtscGraphLookup {
15
10
  /** Find a concrete class, method, function, property, type, or dotted handle. */
@@ -17,26 +12,23 @@ export declare namespace ITtscGraphLookup {
17
12
  /** Discriminator for targeted symbol lookup. */
18
13
  type: "lookup";
19
14
  /**
20
- * What to find, in natural language and code vocabulary mixed freely: a
21
- * symbol name, a dotted member (`Service.create`), or a short phrase
22
- * (`request handler`). Exact names are not required, but this is not a
23
- * second broad entrypoints call. Use it when a named handle is missing or
24
- * ambiguous.
15
+ * What to find: a symbol name, a dotted member (`Service.create`), or a
16
+ * short phrase (`request handler`). Exact names are not required, but this
17
+ * is not a second broad entrypoints call; use it for a missing or ambiguous
18
+ * named handle.
25
19
  */
26
20
  query: string;
27
21
  /**
28
- * Maximum hits to return.
29
- *
30
- * Prefer the default. Large hit lists usually mean the query is too broad;
31
- * refine the name instead of raising this.
22
+ * Maximum hits to return. A large hit list usually means the query is too
23
+ * broad; refine the name instead of raising this.
32
24
  *
33
25
  * @default 5
34
26
  */
35
27
  limit?: number;
36
28
  /**
37
29
  * Include dependency-boundary declarations from node_modules or bundled
38
- * `.d.ts` libraries. Leave false for project-source answers; enable only
39
- * when external type/API boundaries are the question.
30
+ * `.d.ts` libraries. Enable only when external type/API boundaries are the
31
+ * question.
40
32
  *
41
33
  * @default false
42
34
  */
@@ -54,10 +46,7 @@ export declare namespace ITtscGraphLookup {
54
46
  file: string;
55
47
  /** 1-based declaration line, when known. */
56
48
  line?: number;
57
- /**
58
- * The hit's declaration signature, so you can often answer without
59
- * requesting details.
60
- */
49
+ /** Declaration signature, often enough to answer without a `details` call. */
61
50
  signature?: string;
62
51
  /** Decorators written on this declaration, when any. */
63
52
  decorators?: ITtscGraphDecorator[];
@@ -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
- /** Smallest graph request type to use when `action` is `inspect`. */
14
+ /** The single graph request type to use when `action` is `inspect`. */
12
15
  request?: "entrypoints" | "lookup" | "trace" | "details" | "overview" | "tour";
13
- /** Why the returned graph evidence supports that action. */
16
+ /** Why the returned evidence supports that action. */
14
17
  reason: string;
15
18
  }
@@ -27,25 +27,34 @@ export interface ITtscGraphNode {
27
27
  /** Project-relative path of the file that declares this node. */
28
28
  file: string;
29
29
  /**
30
- * True when the declaration lives outside the workspace (a dependency). The
31
- * graph keeps the leaf as a named endpoint but does not walk into its
32
- * internals.
30
+ * True when the declaration is outside the workspace (a dependency): kept as
31
+ * a named endpoint, not walked into.
33
32
  */
34
33
  external: boolean;
35
34
  /**
36
- * True when `file` is git-ignored generated code (a Prisma client, a codegen
37
- * output). Projections desurface these so generated nodes do not bury the
35
+ * True when `file` is git-ignored generated code (Prisma client, codegen
36
+ * output); projections desurface these so generated nodes do not bury the
38
37
  * authored graph.
39
38
  */
40
39
  ignored?: boolean;
41
40
  /** True when the symbol is part of its module's export surface. */
42
41
  exported?: boolean;
42
+ /**
43
+ * True for a declaration made inside another declaration's body: Vue's
44
+ * `baseCreateRenderer.patch`, a callback bound to a const inside a method.
45
+ *
46
+ * It is a name the runtime calls, so a trace, a lookup, or a details request
47
+ * answers with it. An orientation tour does not rank or walk it: a tour is
48
+ * asked what the project's surface is and how it runs, and a body's inner
49
+ * functions are neither — letting them into the seed ranking reshuffled which
50
+ * flows a tour told, and the model went back to the files.
51
+ */
52
+ closure?: boolean;
43
53
  /** Declaration modifiers, when the declaration pass recorded any. */
44
54
  modifiers?: TtscGraphNodeModifier[];
45
55
  /**
46
- * The decorators written on this declaration, in source order, when it has
47
- * any: raw decorator facts (`@Controller`, `@Get`) a consumer can interpret
48
- * without re-parsing source.
56
+ * Decorators written on this declaration, in source order: raw facts
57
+ * (`@Controller`, `@Get`) a consumer interprets without re-parsing source.
49
58
  */
50
59
  decorators?: ITtscGraphDecorator[];
51
60
  /** The declaration span, for display and signatures. */
@@ -1,4 +1,3 @@
1
- import { ITtscGraphNext } from "./ITtscGraphNext";
2
1
  /** A compact, source-read-free project map for broad orientation only. */
3
2
  export interface ITtscGraphOverview {
4
3
  /** Discriminator for source-free project overview. */
@@ -7,10 +6,6 @@ export interface ITtscGraphOverview {
7
6
  project: string;
8
7
  /** Size of the graph. */
9
8
  counts: ITtscGraphOverview.ICounts;
10
- /** How to use this source-free result next. */
11
- next: ITtscGraphNext;
12
- /** Human-readable compatibility note mirroring `next`. */
13
- guide: string;
14
9
  /** Folder layering, largest first. */
15
10
  layers?: ITtscGraphOverview.ILayer[];
16
11
  /** Highest-dependency symbols, busiest first. */
@@ -24,13 +19,15 @@ export declare namespace ITtscGraphOverview {
24
19
  /** Discriminator for source-free project overview. */
25
20
  type: "overview";
26
21
  /**
27
- * The facet to project, or `all` for every facet. `layers` is the folder
28
- * layering, `hotspots` the highest-dependency symbols, `publicApi` the
29
- * exported API symbols ranked by how depended-on they are.
22
+ * Facet to project, or `all` for every facet:
30
23
  *
31
- * Use this only for broad public API or layer orientation. For behavior,
32
- * lifecycle, request-flow, rendering-flow, validation-flow, caller, or
33
- * dependency questions, use `entrypoints` then `trace` instead.
24
+ * - `layers`: folder layering
25
+ * - `hotspots`: highest-dependency symbols
26
+ * - `publicApi`: exported API symbols ranked by how depended-on they are
27
+ *
28
+ * Broad public-API or layer orientation only. For behavior, lifecycle,
29
+ * request/render/validation flow, caller, or dependency questions, use
30
+ * `entrypoints` then `trace`.
34
31
  *
35
32
  * @default "all"
36
33
  */
@@ -77,9 +74,8 @@ export declare namespace ITtscGraphOverview {
77
74
  fanOut: number;
78
75
  }
79
76
  /**
80
- * One symbol on the project's exported public API surface. The list is ranked
81
- * by how depended-on the symbol is, with test, typings, and generated files
82
- * excluded.
77
+ * One exported public-API symbol. The list is ranked by how depended-on the
78
+ * symbol is, excluding test, typings, and generated files.
83
79
  */
84
80
  type IPublicApi = INode;
85
81
  }
@@ -0,0 +1,29 @@
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
+ /** 1-based line where the span starts. */
22
+ startLine: number;
23
+ /** 1-based column where the span starts, when known. */
24
+ startCol?: number;
25
+ /** 1-based line where the span ends, when known. */
26
+ endLine?: number;
27
+ /** 1-based column where the span ends, when known. */
28
+ endCol?: number;
29
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscGraphDiagnostic.js.map
3
+ //# sourceMappingURL=ITtscGraphSpan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscGraphSpan.js","sourceRoot":"","sources":["../../src/structures/ITtscGraphSpan.ts"],"names":[],"mappings":""}
@@ -1,11 +1,8 @@
1
1
  import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
- import { ITtscGraphNext } from "./ITtscGraphNext";
3
2
  /** Answer-ready, source-free tour evidence for broad code-flow questions. */
4
3
  export interface ITtscGraphTour {
5
4
  /** Discriminator for code-tour indexing. */
6
5
  type: "tour";
7
- /** Natural code question this tour was built for. */
8
- query: string;
9
6
  /** Central entrypoints selected for the tour. */
10
7
  entrypoints: ITtscGraphTour.INode[];
11
8
  /** Selected primary runtime flows; sufficient for an index-level tour. */
@@ -16,31 +13,48 @@ export interface ITtscGraphTour {
16
13
  tests: ITtscGraphTour.IAnchor[];
17
14
  /** Ordered file/line anchors to cite in the final answer, not file reads. */
18
15
  answerAnchors: ITtscGraphTour.IAnchor[];
19
- /** How to use this source-free result next. */
20
- next: ITtscGraphNext;
21
- /** Human-readable compatibility note mirroring `next`. */
22
- guide: string;
23
- /** True when any internal slice hit its cap. */
16
+ /** True when some low-signal extras were capped; the returned tour stands. */
24
17
  truncated?: boolean;
25
18
  }
26
19
  export declare namespace ITtscGraphTour {
27
20
  /**
28
- * Build the complete index-level answer surface for broad code tours: central
29
- * entrypoints, primary flow, nearby paths, tests, and answer anchors. Use
30
- * this instead of decomposing repository-orientation, read-next,
31
- * architecture, or multi-phase runtime-flow questions into many
32
- * lookup/details/trace calls.
21
+ * A broad code tour: entrypoints, primary flow, nearby paths, and tests.
22
+ *
23
+ * It asks for no question of its own — it ranks against the `question` the
24
+ * caller has already written, in the user's words.
33
25
  */
34
26
  interface IRequest {
35
27
  /** Discriminator for code-tour indexing. */
36
28
  type: "tour";
37
- /** The user's natural code-tour question. */
38
- query: string;
39
29
  /**
40
- * Maximum central entrypoints to seed the tour.
30
+ * Symbol names, never a sentence: the machinery you expect the answer to be
31
+ * made of, spelled the way this codebase would spell it. A question about
32
+ * how a job reaches a worker is reinterpreted as `["JobQueue.push",
33
+ * "Scheduler.tick", "Worker.run", "drainQueue"]`.
41
34
  *
42
- * Prefer the default. Raise only when the question names several distinct
43
- * public paths that must all appear in one answer.
35
+ * Write them from the question, before you have seen a line of the code. A
36
+ * codebase names many things alike, and the question's own words cannot
37
+ * tell them apart: a question about _tracking_ matches the debug hook named
38
+ * after tracking as readily as the function that does it, and one about a
39
+ * _request_ matches a message listener as readily as an HTTP router. The
40
+ * names say which you meant.
41
+ *
42
+ * Each is resolved like a handle — a symbol name, a `Class.member`. The
43
+ * ones the graph holds take half the tour's entrypoints, the rest stays
44
+ * with what the graph finds central, and a name it does not know, or knows
45
+ * several of, is dropped. So a wrong guess costs nothing, and a specific
46
+ * name is worth more than a general one: `drainQueue` resolves, `queue`
47
+ * does not.
48
+ *
49
+ * Send `[]` when the question names no machinery — "show me the central
50
+ * flow" in a repository you have never seen. There is nothing to
51
+ * reinterpret then: the tour ranks on structure, which is what that
52
+ * question asks for. Do not look names up first to fill this.
53
+ */
54
+ reinterpretations: string[];
55
+ /**
56
+ * Central entrypoints to seed the tour. Raise only when the question names
57
+ * several public paths that must all appear in one answer.
44
58
  *
45
59
  * @default 4
46
60
  */
@@ -68,6 +82,12 @@ export declare namespace ITtscGraphTour {
68
82
  sourceSpan?: ITtscGraphTour.ISpan;
69
83
  /** Declaration head, when available. */
70
84
  signature?: string;
85
+ /**
86
+ * The first sentence of the doc comment above the declaration: what the
87
+ * project says this symbol is for. A name and an edge say what calls what;
88
+ * this says why, which is what a tour is asked for.
89
+ */
90
+ doc?: string;
71
91
  /** Decorators written on the declaration, when any. */
72
92
  decorators?: ITtscGraphDecorator[];
73
93
  }
@@ -77,13 +97,35 @@ export declare namespace ITtscGraphTour {
77
97
  start: ITtscGraphTour.INode;
78
98
  /** Compact edge summaries in graph order. */
79
99
  steps: string[];
80
- /** Nodes reached by this flow. */
81
- reached: ITtscGraphTour.INode[];
82
- /** Edge and node anchors that explain the flow. */
83
- anchors: ITtscGraphTour.IAnchor[];
84
- /** True when the flow hit graph caps. */
100
+ /**
101
+ * Every node this flow reached, with the handle to call the graph with
102
+ * next.
103
+ *
104
+ * A step is prose — it names both of its ends and the file and line the
105
+ * call sits on — and it carries no handle. So the nodes a step names are
106
+ * listed here too: `steps` is the story, `reached` is what to go on with.
107
+ */
108
+ reached: ITtscGraphTour.IReached[];
109
+ /** True when some low-signal flow steps were capped; the flow stands. */
85
110
  truncated?: boolean;
86
111
  }
112
+ /**
113
+ * A node a flow reached, as its handle and its declaration line.
114
+ *
115
+ * A node id _is_ its coordinates — `path/to/file.ts#Owner.member:kind` — so a
116
+ * reached node carrying `file` and `kind` beside it bought the same fact
117
+ * three times. Across the benchmark corpus that repetition was 15% of every
118
+ * tour, and a tour is re-sent whole on every turn of the conversation it
119
+ * opened.
120
+ */
121
+ interface IReached {
122
+ /** Stable node id for later graph calls: `file#Qualified.Name:kind`. */
123
+ id: string;
124
+ /** Qualified symbol name when available, otherwise the simple name. */
125
+ name: string;
126
+ /** 1-based declaration line, when known. */
127
+ line?: number;
128
+ }
87
129
  /** A file/line citation chosen by the graph, not source body text. */
88
130
  interface IAnchor {
89
131
  /** Why this anchor matters in the tour. */
@@ -1,5 +1,4 @@
1
1
  import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
2
- import { ITtscGraphNext } from "./ITtscGraphNext";
3
2
  /** The compact dependency or caller flow returned from a selected start symbol. */
4
3
  export interface ITtscGraphTrace {
5
4
  /** Discriminator for dependency tracing. */
@@ -12,86 +11,119 @@ export interface ITtscGraphTrace {
12
11
  hops: ITtscGraphTrace.IHop[];
13
12
  /** Unique nodes reached (excluding the start), each with its depth and roles. */
14
13
  reached: ITtscGraphTrace.INode[];
15
- /** True when the trace hit maxNodes or maxDepth and more flow exists. */
14
+ /** True when the trace hit its node or depth cap; the returned flow stands. */
16
15
  truncated: boolean;
17
16
  /** The resolved `to` target, when a path was requested. */
18
17
  target?: ITtscGraphTrace.INode;
19
18
  /**
20
- * When `to` was given: the ordered dependency path from `from` to `to`
21
- * (`from` first, `to` last), or empty when `to` is not reachable from
22
- * `from`.
19
+ * Ordered dependency path from `from` to `to` when `to` was given (`from`
20
+ * first, `to` last), empty when `to` is unreachable.
23
21
  */
24
22
  path?: ITtscGraphTrace.INode[];
25
23
  /** Compact hop summaries preserving node names and edge evidence, capped. */
26
24
  steps?: string[];
27
- /** How to use this source-free result next. */
28
- next: ITtscGraphNext;
29
- /** Human-readable compatibility note mirroring `next`. */
30
- guide: string;
25
+ /**
26
+ * Symbols both ends touch, when no call path runs between them.
27
+ *
28
+ * Nothing calls across the gap because in an event-driven codebase nothing
29
+ * does: a handler registers a listener on an emitter, the emitter's `emit()`
30
+ * runs whatever a registration put in an array, and no call edge crosses that
31
+ * array. But both ends touch the emitter, and that is an edge, not a guess —
32
+ * Excalidraw's pointer handler and its store's emit both reference
33
+ * `Store.onDurableIncrementEmitter`, which is exactly the seam the call graph
34
+ * cannot walk.
35
+ *
36
+ * A junction is not a path. It is the symbol to look at next, and the edges
37
+ * that say why.
38
+ */
39
+ junctions?: ITtscGraphTrace.IJunction[];
31
40
  /** When `from` was an ambiguous name, the matches to disambiguate with. */
32
41
  candidates?: ITtscGraphTrace.INode[];
33
42
  }
34
43
  export declare namespace ITtscGraphTrace {
44
+ /** A symbol both ends of an unreachable path touch, and how each touches it. */
45
+ interface IJunction {
46
+ /** Stable node id: trace or inspect this symbol to cross the seam. */
47
+ id: string;
48
+ /** Qualified symbol name when available, otherwise the simple name. */
49
+ name: string;
50
+ /** Declaration kind (`variable`, `method`, `class`, ...). */
51
+ kind: string;
52
+ /** Project-relative path of the file that declares it. */
53
+ file: string;
54
+ /** 1-based declaration line, when known. */
55
+ line?: number;
56
+ /** How the start reaches it: the edge kind, and where that edge sits. */
57
+ fromStart: IJunctionEdge;
58
+ /** How the target reaches it, or is reached from it. */
59
+ fromTarget: IJunctionEdge;
60
+ }
61
+ /** One edge between an end of the requested path and the junction. */
62
+ interface IJunctionEdge {
63
+ /** `calls`, `accesses`, `instantiates`, `type_ref`, ... */
64
+ kind: string;
65
+ /** True when the end is the edge's source, false when it is the target. */
66
+ outgoing: boolean;
67
+ /** Where the reference sits in source. */
68
+ evidence?: ITtscGraphEvidence;
69
+ }
35
70
  /** Where and how far to trace dependency flow. */
36
71
  interface IRequest {
37
72
  /** Discriminator for dependency tracing. */
38
73
  type: "trace";
39
74
  /**
40
- * Where to start: a node id from another tool, a simple symbol name, or a
41
- * dotted member name such as `OrderService.create`. An ambiguous name
42
- * returns its candidates instead of a trace.
75
+ * Where to start: a node id, a simple symbol name, or a dotted member
76
+ * (`OrderService.create`). An ambiguous name returns its candidates instead
77
+ * of a trace.
43
78
  */
44
79
  from: string;
45
80
  /**
46
- * A target symbol: node id, simple symbol name, or dotted member name. When
47
- * given, the tool returns the dependency path from `from` to this target,
48
- * the one-call answer for "how does A reach B", instead of an open-ended
49
- * trace. Prefer this path mode whenever both ends are known.
81
+ * Target symbol (node id, simple name, or dotted member). When given, the
82
+ * tool returns the dependency path from `from` to it, the one-call answer
83
+ * for "how does A reach B". Prefer this path mode whenever both ends are
84
+ * known.
50
85
  */
51
86
  to?: string;
52
87
  /**
53
- * `forward` follows what the start uses (callees, instantiations, renders);
54
- * `reverse` follows what uses the start (callers); `impact` is a reverse
55
- * trace that prioritizes public API and test nodes a change would reach.
56
- * Its test nodes are semantic usage edges, not a text-search inventory.
57
- * Caller questions usually fit `reverse`.
88
+ * Trace direction:
89
+ *
90
+ * - `forward`: what the start uses (callees, instantiations, renders)
91
+ * - `reverse`: what uses the start (callers); the usual fit for caller
92
+ * questions
93
+ * - `impact`: reverse trace prioritizing public API and test nodes a change
94
+ * reaches; its test nodes are semantic usage edges, not a text search
58
95
  *
59
96
  * @default "forward"
60
97
  */
61
98
  direction?: "forward" | "reverse" | "impact";
62
99
  /**
63
- * Which non-structural edge family to follow: `execution` follows runtime
64
- * calls, instantiations, property access, and JSX renders; `types` follows
65
- * type references and inheritance; `all` preserves the full graph. Flow
66
- * questions should usually choose `execution` rather than `all`.
100
+ * Non-structural edge family to follow:
101
+ *
102
+ * - `execution`: runtime calls, instantiations, property access, JSX renders
103
+ * - `types`: type references and inheritance
104
+ * - `all`: the full graph
105
+ *
106
+ * Flow questions usually want `execution`, not `all`.
67
107
  *
68
108
  * @default "all"
69
109
  */
70
110
  focus?: "all" | "execution" | "types";
71
111
  /**
72
- * How many hops deep to follow. Open forward/reverse traces are capped at
73
- * 2; impact traces at 4; path mode at 12.
74
- *
75
- * Prefer the default for open traces. Raise only for path mode or when the
76
- * previous trace named the missing next hop.
112
+ * Hops deep to follow (open forward/reverse cap at 8, impact at 4, path
113
+ * mode at 12). Raise it to follow a runtime chain to its end in one call.
77
114
  *
78
- * @default 2
115
+ * @default 3
79
116
  */
80
117
  maxDepth?: number;
81
118
  /**
82
- * Cap on reached nodes; the trace stops and marks itself truncated past it.
83
- * Open forward/reverse traces are capped at 8 nodes, impact at 16 nodes.
119
+ * Cap on reached nodes (open forward/reverse cap at 32, impact at 16).
84
120
  *
85
- * Prefer the default; use larger open traces only when a named missing edge
86
- * requires it.
87
- *
88
- * @default 6
121
+ * @default 12
89
122
  */
90
123
  maxNodes?: number;
91
124
  /**
92
125
  * Include dependency-boundary nodes from node_modules or bundled `.d.ts`
93
- * libraries. Leave false for source-flow tours; enable only when the user
94
- * asks about external type/API boundaries.
126
+ * libraries. Enable only for questions about external type/API boundaries.
95
127
  *
96
128
  * @default false
97
129
  */
@@ -107,17 +139,8 @@ export declare namespace ITtscGraphTrace {
107
139
  kind: string;
108
140
  /** Hops from the start (1 = direct). */
109
141
  depth: number;
110
- /**
111
- * Source span for the expression that produced this hop. It is repository
112
- * evidence for the hop and can be cited without opening the file.
113
- */
142
+ /** Source span that produced the hop: citable without opening the file. */
114
143
  evidence?: ITtscGraphEvidence;
115
- /**
116
- * Stable access-path aliases derived from edge evidence. These preserve a
117
- * resolved member's owner and the concrete property path used at the call
118
- * site.
119
- */
120
- aliases?: string[];
121
144
  }
122
145
  /** A node on the trace: the start, a reached node, or a candidate. */
123
146
  interface INode {
@@ -6,5 +6,11 @@
6
6
  * `extends`, `implements`, `overrides`, `renders`) are resolved by the checker
7
7
  * — `renders` is a JSX component use. `decorates` carries a decorator fact and
8
8
  * `tests` a test-to-subject relationship.
9
+ *
10
+ * `dispatches` is the runtime counterpart of `overrides`/`implements`: the
11
+ * checker resolves a call to the declaration it names, and where that
12
+ * declaration is abstract or an interface member, the code that runs is its
13
+ * implementation. It carries the implementation's declaration span, and a
14
+ * traversal that follows what executes emits it in place of the dead end.
9
15
  */
10
- export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "decorates" | "renders" | "tests";
16
+ export type TtscGraphEdgeKind = "contains" | "exports" | "imports" | "calls" | "accesses" | "instantiates" | "type_ref" | "extends" | "implements" | "overrides" | "dispatches" | "decorates" | "renders" | "tests";
@@ -1,6 +1,5 @@
1
1
  export * from "./ITtscGraphApplication";
2
2
  export * from "./ITtscGraphDecorator";
3
- export * from "./ITtscGraphDiagnostic";
4
3
  export * from "./ITtscGraphDump";
5
4
  export * from "./ITtscGraphEdge";
6
5
  export * from "./ITtscGraphEvidence";
@@ -12,6 +11,7 @@ export * from "./ITtscGraphOverview";
12
11
  export * from "./ITtscGraphLookup";
13
12
  export * from "./ITtscGraphNext";
14
13
  export * from "./ITtscGraphTrace";
14
+ export * from "./ITtscGraphSpan";
15
15
  export * from "./ITtscGraphTour";
16
16
  export * from "./TtscGraphEdgeKind";
17
17
  export * from "./TtscGraphNodeKind";