@ttsc/graph 0.16.4 → 0.16.6

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 (115) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -53
  3. package/lib/TtscGraphApplication.js +59 -0
  4. package/lib/TtscGraphApplication.js.map +1 -0
  5. package/lib/index.js +31 -108
  6. package/lib/index.js.map +1 -1
  7. package/lib/model/TtscGraphMemory.js +185 -0
  8. package/lib/model/TtscGraphMemory.js.map +1 -0
  9. package/lib/model/loadGraph.js +418 -0
  10. package/lib/model/loadGraph.js.map +1 -0
  11. package/lib/reduce.js +101 -0
  12. package/lib/reduce.js.map +1 -0
  13. package/lib/resolveGraphBinary.js +42 -0
  14. package/lib/resolveGraphBinary.js.map +1 -0
  15. package/lib/server/accessAliases.js +53 -0
  16. package/lib/server/accessAliases.js.map +1 -0
  17. package/lib/server/createServer.js +1726 -0
  18. package/lib/server/createServer.js.map +1 -0
  19. package/lib/server/instructions.js +80 -0
  20. package/lib/server/instructions.js.map +1 -0
  21. package/lib/server/resolveHandle.js +25 -0
  22. package/lib/server/resolveHandle.js.map +1 -0
  23. package/lib/server/runDetails.js +413 -0
  24. package/lib/server/runDetails.js.map +1 -0
  25. package/lib/server/runEntrypoints.js +211 -0
  26. package/lib/server/runEntrypoints.js.map +1 -0
  27. package/lib/server/runLookup.js +234 -0
  28. package/lib/server/runLookup.js.map +1 -0
  29. package/lib/server/runOverview.js +160 -0
  30. package/lib/server/runOverview.js.map +1 -0
  31. package/lib/server/runTrace.js +314 -0
  32. package/lib/server/runTrace.js.map +1 -0
  33. package/lib/server/startServer.js +21 -0
  34. package/lib/server/startServer.js.map +1 -0
  35. package/lib/structures/ITtscGraphApplication.js +3 -0
  36. package/lib/structures/ITtscGraphApplication.js.map +1 -0
  37. package/lib/structures/ITtscGraphDecorator.js +3 -0
  38. package/lib/structures/ITtscGraphDecorator.js.map +1 -0
  39. package/lib/structures/ITtscGraphDetails.js +3 -0
  40. package/lib/structures/ITtscGraphDetails.js.map +1 -0
  41. package/lib/structures/ITtscGraphDiagnostic.js +3 -0
  42. package/lib/structures/ITtscGraphDiagnostic.js.map +1 -0
  43. package/lib/structures/ITtscGraphDump.js +3 -0
  44. package/lib/structures/ITtscGraphDump.js.map +1 -0
  45. package/lib/structures/ITtscGraphEdge.js +3 -0
  46. package/lib/structures/ITtscGraphEdge.js.map +1 -0
  47. package/lib/structures/ITtscGraphEntrypoints.js +3 -0
  48. package/lib/structures/ITtscGraphEntrypoints.js.map +1 -0
  49. package/lib/structures/ITtscGraphEscape.js +3 -0
  50. package/lib/structures/ITtscGraphEscape.js.map +1 -0
  51. package/lib/structures/ITtscGraphEvidence.js +3 -0
  52. package/lib/structures/ITtscGraphEvidence.js.map +1 -0
  53. package/lib/structures/ITtscGraphLookup.js +3 -0
  54. package/lib/structures/ITtscGraphLookup.js.map +1 -0
  55. package/lib/structures/ITtscGraphNode.js +3 -0
  56. package/lib/structures/ITtscGraphNode.js.map +1 -0
  57. package/lib/structures/ITtscGraphOverview.js +3 -0
  58. package/lib/structures/ITtscGraphOverview.js.map +1 -0
  59. package/lib/structures/ITtscGraphTrace.js +3 -0
  60. package/lib/structures/ITtscGraphTrace.js.map +1 -0
  61. package/lib/structures/TtscGraphEdgeKind.js +3 -0
  62. package/lib/structures/TtscGraphEdgeKind.js.map +1 -0
  63. package/lib/structures/TtscGraphNodeKind.js +3 -0
  64. package/lib/structures/TtscGraphNodeKind.js.map +1 -0
  65. package/lib/structures/TtscGraphNodeModifier.js +3 -0
  66. package/lib/structures/TtscGraphNodeModifier.js.map +1 -0
  67. package/lib/structures/index.js +38 -0
  68. package/lib/structures/index.js.map +1 -0
  69. package/lib/view.js +140 -0
  70. package/lib/view.js.map +1 -0
  71. package/lib/viewer/index.html +123 -0
  72. package/lib/viewer/viewer.js +4610 -0
  73. package/package.json +17 -4
  74. package/src/TtscGraphApplication.ts +64 -0
  75. package/src/index.ts +40 -126
  76. package/src/model/TtscGraphMemory.ts +204 -0
  77. package/src/model/loadGraph.ts +85 -0
  78. package/src/reduce.ts +165 -0
  79. package/src/resolveGraphBinary.ts +40 -0
  80. package/src/server/accessAliases.ts +55 -0
  81. package/src/server/createServer.ts +101 -0
  82. package/src/server/instructions.ts +76 -0
  83. package/src/server/resolveHandle.ts +34 -0
  84. package/src/server/runDetails.ts +469 -0
  85. package/src/server/runEntrypoints.ts +256 -0
  86. package/src/server/runLookup.ts +257 -0
  87. package/src/server/runOverview.ts +166 -0
  88. package/src/server/runTrace.ts +359 -0
  89. package/src/server/startServer.ts +25 -0
  90. package/src/structures/ITtscGraphApplication.ts +116 -0
  91. package/src/structures/ITtscGraphDecorator.ts +31 -0
  92. package/src/structures/ITtscGraphDetails.ts +134 -0
  93. package/src/structures/ITtscGraphDiagnostic.ts +34 -0
  94. package/src/structures/ITtscGraphDump.ts +35 -0
  95. package/src/structures/ITtscGraphEdge.ts +24 -0
  96. package/src/structures/ITtscGraphEntrypoints.ts +118 -0
  97. package/src/structures/ITtscGraphEscape.ts +39 -0
  98. package/src/structures/ITtscGraphEvidence.ts +26 -0
  99. package/src/structures/ITtscGraphLookup.ts +61 -0
  100. package/src/structures/ITtscGraphNode.ts +70 -0
  101. package/src/structures/ITtscGraphOverview.ts +87 -0
  102. package/src/structures/ITtscGraphTrace.ts +140 -0
  103. package/src/structures/TtscGraphEdgeKind.ts +23 -0
  104. package/src/structures/TtscGraphNodeKind.ts +26 -0
  105. package/src/structures/TtscGraphNodeModifier.ts +19 -0
  106. package/src/structures/index.ts +22 -0
  107. package/src/view.ts +155 -0
  108. package/src/viewer/index.html +123 -0
  109. package/src/viewer/main.ts +209 -0
  110. package/lib/bin.d.ts +0 -2
  111. package/lib/diagnostics.d.ts +0 -23
  112. package/lib/diagnostics.js +0 -84
  113. package/lib/diagnostics.js.map +0 -1
  114. package/lib/index.d.ts +0 -29
  115. package/src/diagnostics.ts +0 -93
@@ -0,0 +1,35 @@
1
+ import { ITtscGraphDiagnostic } from "./ITtscGraphDiagnostic";
2
+ import { ITtscGraphEdge } from "./ITtscGraphEdge";
3
+ import { ITtscGraphNode } from "./ITtscGraphNode";
4
+
5
+ /**
6
+ * The whole-graph export `ttscgraph dump` writes and the MCP server loads — the
7
+ * wire contract between the Go fact-builder and the TypeScript graph engine.
8
+ *
9
+ * It is the complete graph with none of the per-response caps the MCP tools
10
+ * apply: every node and edge the build resolved. The server parses it once at
11
+ * startup (typia-validated) into an in-memory resident graph and answers every
12
+ * tool call from that warm model; the bundled 3D viewer reduces the same dump.
13
+ *
14
+ * Paths in `project` and `tsconfig` are absolute; `file` fields on nodes,
15
+ * edges, and diagnostics are project-relative.
16
+ */
17
+ export interface ITtscGraphDump {
18
+ /** Absolute path of the project root the graph was built for. */
19
+ project: string;
20
+
21
+ /** The tsconfig the program was loaded from, relative to `project`. */
22
+ tsconfig: string;
23
+
24
+ /** Every node the build recorded. */
25
+ nodes: ITtscGraphNode[];
26
+
27
+ /** Every edge the build resolved. */
28
+ edges: ITtscGraphEdge[];
29
+
30
+ /**
31
+ * Fused compiler and plugin diagnostics, when diagnostics were collected.
32
+ * Absent when the dump was built without a diagnostics pass.
33
+ */
34
+ diagnostics?: ITtscGraphDiagnostic[];
35
+ }
@@ -0,0 +1,24 @@
1
+ import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
2
+ import { TtscGraphEdgeKind } from "./TtscGraphEdgeKind";
3
+
4
+ /**
5
+ * A directed relationship from one {@link ITtscGraphNode} to another, both named
6
+ * by `id`. The triple `(from, to, kind)` is unique; a repeated relationship
7
+ * keeps the first source-order evidence.
8
+ *
9
+ * Every edge is resolved by the compiler, so there is no per-edge trust flag to
10
+ * carry — the whole graph is checker-resolved fact.
11
+ */
12
+ export interface ITtscGraphEdge {
13
+ /** Node id the relationship originates from. */
14
+ from: string;
15
+
16
+ /** Node id the relationship points to. */
17
+ to: string;
18
+
19
+ /** The relationship kind. */
20
+ kind: TtscGraphEdgeKind;
21
+
22
+ /** The source expression that produced the edge, for display and expansion. */
23
+ evidence?: ITtscGraphEvidence;
24
+ }
@@ -0,0 +1,118 @@
1
+ import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
+ import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
3
+
4
+ /** The compact source-free entrypoint list returned for a code question. */
5
+ export interface ITtscGraphEntrypoints {
6
+ /** Discriminator for first-pass question indexing. */
7
+ type: "entrypoints";
8
+
9
+ /** The original question/search phrase the entrypoints were built for. */
10
+ query: string;
11
+
12
+ /** Ranked symbols relevant to the query. */
13
+ hits: ITtscGraphEntrypoints.IHit[];
14
+
15
+ /** Code handles written directly in the query, resolved when possible. */
16
+ mentions: ITtscGraphEntrypoints.IMention[];
17
+
18
+ /** Direct dependency context for the resolved mentions and highest hits. */
19
+ neighborhood: ITtscGraphEntrypoints.INeighborhood[];
20
+
21
+ /** Follow-up handles for deeper graph calls. */
22
+ next: ITtscGraphEntrypoints.INext;
23
+
24
+ /** True when result caps hid additional seeds or references. */
25
+ truncated?: boolean;
26
+ }
27
+
28
+ export namespace ITtscGraphEntrypoints {
29
+ /**
30
+ * Ask the graph for the first entrypoints an agent should read before opening
31
+ * source: ranked symbols, exact mentioned handles, and nearby dependency
32
+ * edges.
33
+ */
34
+ export interface IRequest {
35
+ /** Discriminator for first-pass question indexing. */
36
+ type: "entrypoints";
37
+
38
+ /**
39
+ * A natural code question or search phrase. Mix prose with code handles,
40
+ * for example `how Repository.find loads relations` or
41
+ * `SelectQueryBuilder.setFindOptions join aliases`.
42
+ */
43
+ query: string;
44
+
45
+ /**
46
+ * Maximum ranked hits to return.
47
+ *
48
+ * @default 4
49
+ */
50
+ limit?: number;
51
+
52
+ /**
53
+ * Maximum direct dependencies and dependents to return per indexed symbol.
54
+ * This is an orientation slice, not a dependency dump; use `trace` or
55
+ * `details` with `neighbors:true` after choosing the specific handles.
56
+ *
57
+ * @default 0
58
+ */
59
+ neighbors?: number;
60
+ }
61
+
62
+ /** A compact symbol coordinate, optionally with its declaration signature. */
63
+ export interface INode {
64
+ id: string;
65
+ name: string;
66
+ kind: string;
67
+ file: string;
68
+ /** 1-based declaration line, when known. */
69
+ line?: number;
70
+ /** Declaration head, included only for indexed symbols. */
71
+ signature?: string;
72
+ /** Decorators written on this declaration, when any. */
73
+ decorators?: ITtscGraphDecorator[];
74
+ }
75
+
76
+ /** One ranked search hit. */
77
+ export interface IHit extends INode {
78
+ /** Relative relevance; higher is a better match. */
79
+ score: number;
80
+ }
81
+
82
+ /** A code handle written in the query, with its resolution status. */
83
+ export interface IMention {
84
+ handle: string;
85
+ node?: INode;
86
+ candidates?: INode[];
87
+ }
88
+
89
+ /** Direct dependency context around one indexed symbol. */
90
+ export interface INeighborhood extends INode {
91
+ dependsOn: IReference[];
92
+ dependedOnBy: IReference[];
93
+ }
94
+
95
+ /** One neighboring symbol and the relationship leading to it. */
96
+ export interface IReference {
97
+ id: string;
98
+ name: string;
99
+ kind: string;
100
+ file: string;
101
+ /** 1-based declaration line, when known. */
102
+ line?: number;
103
+ relation: string;
104
+ /**
105
+ * Source span for the expression that produced this relationship. It lets
106
+ * an agent see why the edge exists without opening the file.
107
+ */
108
+ evidence?: ITtscGraphEvidence;
109
+ }
110
+
111
+ /** Tool-call handles suggested by this first entrypoints result. */
112
+ export interface INext {
113
+ /** Pass these ids to `details` for source-free symbol facts. */
114
+ details: string[];
115
+ /** Pass these ids to `trace` when following dependency flow. */
116
+ traceFrom: string[];
117
+ }
118
+ }
@@ -0,0 +1,39 @@
1
+ /** The no-op graph result returned when reasoning rejects the graph call. */
2
+ export interface ITtscGraphEscape {
3
+ /** Discriminator for the no-op escape route. */
4
+ type: "escape";
5
+
6
+ /** Always true so callers can distinguish an intentional no-op. */
7
+ skipped: true;
8
+
9
+ /** Why no graph operation should run. */
10
+ reason: string;
11
+
12
+ /** The next non-graph step, if useful. */
13
+ nextStep?: string;
14
+ }
15
+
16
+ export namespace ITtscGraphEscape {
17
+ /** Exit after the reasoning review decides graph evidence is unnecessary. */
18
+ export interface IRequest {
19
+ /** Discriminator for the no-op escape route. */
20
+ type: "escape";
21
+
22
+ /**
23
+ * Why no graph operation should run.
24
+ *
25
+ * Use this when the review finds the user is asking about package scripts,
26
+ * config files, generated output, prose documentation, or an answer that
27
+ * the current graph result already settled.
28
+ */
29
+ reason: string;
30
+
31
+ /**
32
+ * The next non-graph step, if useful.
33
+ *
34
+ * Keep this short. Examples: `answer from the prior graph result`, `inspect
35
+ * package.json`, or `ask the user for a concrete symbol`.
36
+ */
37
+ nextStep?: string;
38
+ }
39
+ }
@@ -0,0 +1,26 @@
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.
10
+ */
11
+ export interface ITtscGraphEvidence {
12
+ /** Project-relative path of the file the span lives in. */
13
+ file: string;
14
+
15
+ /** 1-based line where the span starts. */
16
+ startLine: number;
17
+
18
+ /** 1-based column where the span starts, when known. */
19
+ startCol?: number;
20
+
21
+ /** 1-based line where the span ends, when it differs from `startLine`. */
22
+ endLine?: number;
23
+
24
+ /** 1-based column where the span ends, when known. */
25
+ endCol?: number;
26
+ }
@@ -0,0 +1,61 @@
1
+ import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
+
3
+ /** The ranked hits returned by targeted symbol lookup. */
4
+ export interface ITtscGraphLookup {
5
+ /** Discriminator for targeted symbol lookup. */
6
+ type: "lookup";
7
+
8
+ hits: ITtscGraphLookup.IHit[];
9
+
10
+ /** Follow-up handles for selected symbol details. */
11
+ next: ITtscGraphLookup.INext;
12
+ }
13
+ export namespace ITtscGraphLookup {
14
+ /** Find the symbols and clusters most relevant to a natural code query. */
15
+ export interface IRequest {
16
+ /** Discriminator for targeted symbol lookup. */
17
+ type: "lookup";
18
+
19
+ /**
20
+ * What to find, in natural language and code vocabulary mixed freely: a
21
+ * symbol name, a dotted member (`OrderService.create`), or a phrase
22
+ * (`shopping order create`, `repository find relations`). Exact names are
23
+ * not required; subword and CamelCase matches rank too.
24
+ */
25
+ query: string;
26
+
27
+ /**
28
+ * Maximum hits to return.
29
+ *
30
+ * @default 5
31
+ */
32
+ limit?: number;
33
+ }
34
+
35
+ /** One ranked hit with a handle to follow via `details` or `trace`. */
36
+ export interface IHit {
37
+ id: string;
38
+ name: string;
39
+ kind: string;
40
+ file: string;
41
+ /** 1-based declaration line, when known. */
42
+ line?: number;
43
+ /**
44
+ * The hit's declaration signature, so you can often answer without
45
+ * requesting details.
46
+ */
47
+ signature?: string;
48
+ /** Decorators written on this declaration, when any. */
49
+ decorators?: ITtscGraphDecorator[];
50
+ /** Relative relevance; higher is a better match. */
51
+ score: number;
52
+ }
53
+
54
+ /** Tool-call handles suggested by this lookup result. */
55
+ export interface INext {
56
+ /** Pass these ids to `details` for source-free symbol facts. */
57
+ details: string[];
58
+ /** Pass these ids to `trace` when following dependency flow. */
59
+ traceFrom: string[];
60
+ }
61
+ }
@@ -0,0 +1,70 @@
1
+ import { ITtscGraphDecorator } from "./ITtscGraphDecorator";
2
+ import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
3
+ import { TtscGraphNodeKind } from "./TtscGraphNodeKind";
4
+ import { TtscGraphNodeModifier } from "./TtscGraphNodeModifier";
5
+
6
+ /**
7
+ * One node in the graph: a declared symbol or a structural container (file,
8
+ * package).
9
+ *
10
+ * The `id` is position-invariant: `path#qualifiedName:kind` (e.g.
11
+ * `src/order.ts#OrderService.create:method`), so inserting a line above a
12
+ * declaration does not re-key it. Line and span live in `evidence` and are
13
+ * never part of identity.
14
+ */
15
+ export interface ITtscGraphNode {
16
+ /** Position-invariant identity (see the interface doc for the id grammar). */
17
+ id: string;
18
+
19
+ /** What this node represents. */
20
+ kind: TtscGraphNodeKind;
21
+
22
+ /** The simple, unqualified declared name (`create`, `OrderService`, `App`). */
23
+ name: string;
24
+
25
+ /**
26
+ * The owner-qualified name, when the node lives inside another declaration:
27
+ * `OrderService.create`, `Shopping.ISale`. Absent for a top-level
28
+ * declaration.
29
+ */
30
+ qualifiedName?: string;
31
+
32
+ /** Project-relative path of the file that declares this node. */
33
+ file: string;
34
+
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.
39
+ */
40
+ external: boolean;
41
+
42
+ /**
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
45
+ * authored graph.
46
+ */
47
+ ignored?: boolean;
48
+
49
+ /** True when the symbol is part of its module's export surface. */
50
+ exported?: boolean;
51
+
52
+ /** Declaration modifiers, when the declaration pass recorded any. */
53
+ modifiers?: TtscGraphNodeModifier[];
54
+
55
+ /**
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.
59
+ */
60
+ decorators?: ITtscGraphDecorator[];
61
+
62
+ /** The declaration span, for display and signatures. */
63
+ evidence?: ITtscGraphEvidence;
64
+
65
+ /**
66
+ * The implementation span when a callable/property member is implemented by a
67
+ * function assignment separate from its declaration.
68
+ */
69
+ implementation?: ITtscGraphEvidence;
70
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * A compact, source-read-free architecture map of the project returned by
3
+ * `overview`.
4
+ */
5
+ export interface ITtscGraphOverview {
6
+ /** Discriminator for source-free project overview. */
7
+ type: "overview";
8
+
9
+ /** Absolute project root. */
10
+ project: string;
11
+
12
+ /** Size of the graph. */
13
+ counts: ITtscGraphOverview.ICounts;
14
+
15
+ /** Folder layering, largest first. */
16
+ layers?: ITtscGraphOverview.ILayer[];
17
+
18
+ /** Highest-dependency symbols, busiest first. */
19
+ hotspots?: ITtscGraphOverview.IHotspot[];
20
+
21
+ /** Exported API symbols, most-depended-on first. */
22
+ publicApi?: ITtscGraphOverview.IPublicApi[];
23
+ }
24
+ export namespace ITtscGraphOverview {
25
+ /** Which architecture facets `overview` should return. */
26
+ export interface IRequest {
27
+ /** Discriminator for source-free project overview. */
28
+ type: "overview";
29
+
30
+ /**
31
+ * The facet to project, or `all` for every facet. `layers` is the folder
32
+ * layering, `hotspots` the highest-dependency symbols, `publicApi` the
33
+ * exported API symbols ranked by how depended-on they are.
34
+ *
35
+ * @default "all"
36
+ */
37
+ aspect?: "all" | "layers" | "hotspots" | "publicApi";
38
+ }
39
+
40
+ /** Size of the graph by node/edge totals and per-kind node counts. */
41
+ export interface ICounts {
42
+ files: number;
43
+ nodes: number;
44
+ edges: number;
45
+ /** Node count per kind. */
46
+ byKind: Record<string, number>;
47
+ }
48
+
49
+ /** One folder layer: its source files and export surface. */
50
+ export interface ILayer {
51
+ /** Directory, project-relative. */
52
+ dir: string;
53
+ /** Distinct source files under it. */
54
+ files: number;
55
+ /** Exported symbols declared under it. */
56
+ exported: number;
57
+ }
58
+
59
+ /** A compact symbol coordinate that can be passed to deeper graph tools. */
60
+ export interface INode {
61
+ /** Stable handle for `details` or `trace`. */
62
+ id: string;
63
+ /** The symbol's qualified name when available. */
64
+ name: string;
65
+ /** Its declaration kind (`class`, `interface`, `function`, ...). */
66
+ kind: string;
67
+ /** Project-relative path of the file that declares it. */
68
+ file: string;
69
+ /** 1-based declaration line, when known. */
70
+ line?: number;
71
+ }
72
+
73
+ /** A high-dependency symbol with its non-structural fan-in and fan-out. */
74
+ export interface IHotspot extends INode {
75
+ /** Non-structural edges pointing at this symbol. */
76
+ fanIn: number;
77
+ /** Non-structural edges leaving this symbol. */
78
+ fanOut: number;
79
+ }
80
+
81
+ /**
82
+ * One symbol on the project's exported public API surface. The list is ranked
83
+ * by how depended-on the symbol is, with test, typings, and generated files
84
+ * excluded.
85
+ */
86
+ export type IPublicApi = INode;
87
+ }
@@ -0,0 +1,140 @@
1
+ import { ITtscGraphEvidence } from "./ITtscGraphEvidence";
2
+
3
+ /** The ordered dependency flow returned from a start symbol. */
4
+ export interface ITtscGraphTrace {
5
+ /** Discriminator for dependency tracing. */
6
+ type: "trace";
7
+
8
+ /** The resolved start node, or undefined when `from` matched nothing. */
9
+ start?: ITtscGraphTrace.INode;
10
+
11
+ direction: string;
12
+
13
+ /** Edges traversed, in breadth-first order. */
14
+ hops: ITtscGraphTrace.IHop[];
15
+
16
+ /** Unique nodes reached (excluding the start), each with its depth and roles. */
17
+ reached: ITtscGraphTrace.INode[];
18
+
19
+ /** True when the trace hit maxNodes or maxDepth and more flow exists. */
20
+ truncated: boolean;
21
+
22
+ /** The resolved `to` target, when a path was requested. */
23
+ target?: ITtscGraphTrace.INode;
24
+
25
+ /**
26
+ * When `to` was given: the ordered dependency path from `from` to `to`
27
+ * (`from` first, `to` last), or empty when `to` is not reachable from
28
+ * `from`.
29
+ */
30
+ path?: ITtscGraphTrace.INode[];
31
+
32
+ /** Compact hop summaries preserving node names and edge evidence, capped. */
33
+ steps?: string[];
34
+
35
+ /** Follow-up handles for inspecting or continuing the trace. */
36
+ next?: ITtscGraphTrace.INext;
37
+
38
+ /** When `from` was an ambiguous name, the matches to disambiguate with. */
39
+ candidates?: ITtscGraphTrace.INode[];
40
+ }
41
+ export namespace ITtscGraphTrace {
42
+ /** Where and how far to trace dependency flow. */
43
+ export interface IRequest {
44
+ /** Discriminator for dependency tracing. */
45
+ type: "trace";
46
+
47
+ /**
48
+ * Where to start: a node id from another tool, a simple symbol name, or a
49
+ * dotted member name such as `OrderService.create`. An ambiguous name
50
+ * returns its candidates instead of a trace.
51
+ */
52
+ from: string;
53
+
54
+ /**
55
+ * A target symbol: node id, simple symbol name, or dotted member name. When
56
+ * given, the tool returns the dependency path from `from` to this target,
57
+ * the one-call answer for "how does A reach B", instead of an open-ended
58
+ * trace.
59
+ */
60
+ to?: string;
61
+
62
+ /**
63
+ * `forward` follows what the start uses (callees, instantiations, renders);
64
+ * `reverse` follows what uses the start (callers); `impact` is a reverse
65
+ * trace that flags the public API and tests a change would reach.
66
+ *
67
+ * @default "forward"
68
+ */
69
+ direction?: "forward" | "reverse" | "impact";
70
+
71
+ /**
72
+ * Which non-structural edge family to follow: `execution` follows runtime
73
+ * calls, instantiations, property access, and JSX renders; `types` follows
74
+ * type references and inheritance; `all` preserves the full graph.
75
+ *
76
+ * @default "all"
77
+ */
78
+ focus?: "all" | "execution" | "types";
79
+
80
+ /**
81
+ * How many hops deep to follow. Open traces are capped at 2; path mode is
82
+ * capped at 12.
83
+ *
84
+ * @default 2
85
+ */
86
+ maxDepth?: number;
87
+
88
+ /**
89
+ * Cap on reached nodes; the trace stops and marks itself truncated past it.
90
+ * Open traces are capped at 10 nodes so a broad graph cannot flood
91
+ * context.
92
+ *
93
+ * @default 6
94
+ */
95
+ maxNodes?: number;
96
+ }
97
+
98
+ /** One traversed edge, with its depth from the start. */
99
+ export interface IHop {
100
+ from: string;
101
+ to: string;
102
+ kind: string;
103
+ /** Hops from the start (1 = direct). */
104
+ depth: number;
105
+ /**
106
+ * Source span for the expression that produced this hop. It lets an agent
107
+ * explain why the trace moves from one symbol to the next without opening
108
+ * the file.
109
+ */
110
+ evidence?: ITtscGraphEvidence;
111
+ /**
112
+ * Stable access-path aliases derived from edge evidence. These preserve a
113
+ * resolved member's owner and the concrete property path used at the call
114
+ * site.
115
+ */
116
+ aliases?: string[];
117
+ }
118
+
119
+ /** A node on the trace: the start, a reached node, or a candidate. */
120
+ export interface INode {
121
+ id: string;
122
+ name: string;
123
+ kind: string;
124
+ file: string;
125
+ /** Hops from the start, on a reached node. */
126
+ depth?: number;
127
+ /** The node's signature, carried on path nodes so the path explains itself. */
128
+ signature?: string;
129
+ /** Why this node matters to an impact trace: `exported`, `test`. */
130
+ roles?: string[];
131
+ }
132
+
133
+ /** Tool-call handles suggested by this trace. */
134
+ export interface INext {
135
+ /** Pass these ids to `details` for selected symbol details. */
136
+ details: string[];
137
+ /** Continue tracing from these ids when the current result is intermediate. */
138
+ traceFrom: string[];
139
+ }
140
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The relationship a directed edge encodes between two {@link ITtscGraphNode}s.
3
+ *
4
+ * Structural edges (`contains`, `exports`, `imports`) come from the declaration
5
+ * pass. Value and type edges (`calls`, `accesses`, `instantiates`, `type_ref`,
6
+ * `extends`, `implements`, `overrides`, `renders`) are resolved by the checker
7
+ * — `renders` is a JSX component use. `decorates` carries a decorator fact and
8
+ * `tests` a test-to-subject relationship.
9
+ */
10
+ export type TtscGraphEdgeKind =
11
+ | "contains"
12
+ | "exports"
13
+ | "imports"
14
+ | "calls"
15
+ | "accesses"
16
+ | "instantiates"
17
+ | "type_ref"
18
+ | "extends"
19
+ | "implements"
20
+ | "overrides"
21
+ | "decorates"
22
+ | "renders"
23
+ | "tests";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What a graph node represents.
3
+ *
4
+ * The symbol kinds (`file` through `parameter`) are declarations the TypeScript
5
+ * program owns and the checker resolves. `external_symbol` is a
6
+ * dependency-boundary leaf the workspace references but does not declare. The
7
+ * graph keeps it as a named endpoint without walking into the dependency's
8
+ * internals.
9
+ *
10
+ * Used as the `kind` discriminant on {@link ITtscGraphNode}.
11
+ */
12
+ export type TtscGraphNodeKind =
13
+ | "file"
14
+ | "package"
15
+ | "namespace"
16
+ | "module"
17
+ | "function"
18
+ | "class"
19
+ | "interface"
20
+ | "type"
21
+ | "enum"
22
+ | "variable"
23
+ | "method"
24
+ | "property"
25
+ | "parameter"
26
+ | "external_symbol";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A declaration modifier carried on a symbol {@link ITtscGraphNode}, when the
3
+ * declaration pass records it. Used by projections that reason about visibility
4
+ * and shape — e.g. a public-API overview filters on `export`, a class outline
5
+ * separates `static` members.
6
+ */
7
+ export type TtscGraphNodeModifier =
8
+ | "export"
9
+ | "default"
10
+ | "declare"
11
+ | "abstract"
12
+ | "static"
13
+ | "readonly"
14
+ | "async"
15
+ | "const"
16
+ | "public"
17
+ | "private"
18
+ | "protected"
19
+ | "optional";